Code Smell: Primitive Obsession [video]
danielbmarkham.com
danielbmarkham.com
Be very careful applying Domain Driven Design to your programs. To make software durable and survive long term, as much of the domain logic should be pushed into the user's world, and not locked into your code, poisoning it. You shouldn't need an engineer to make your program support onboarding a new type of Customer. That shouldn't require a new class and a new type. Think of the "extreme" anti-DDD software of spreadsheets. Almost every company in the world uses Excel or Google Sheets or some spreadsheet software. The business domain stays in user land, as it should. The more you use DDD, the more you poison and lock in your software into business rules that can limit the flexibility of the business, and force engineers to get involved for the business to try new things.
But however you do things, I think you should work hard to ensure that it is easy to avoid accidentally treating, eg, a customer id as a transaction id or SKU id.
No, its not.
> It's an arbitrary grouping of things.
No, its not. Its the conceptual space in which the problem exists that software is solving.
> Sometimes people use it to mean a part of the business
For business software, this is approximately correct (its the part of the business context addressed by the system under design, which usually includes both some aspects of the business and some aspects of the universe outside of the business with which the business interacts.)
> sometimes it's a group of models and actions on those models
This is fairly explicitly wrong; that's a domain model, though confusion between models and the space being modeled is one of the most common cause problems in software engineering.
> and it's all a fundamentally flawed attempt to divide the real world into categories
Arbitrary, perhaps, but the divisions of the real world into “things the system under design is concerned with” and “everything else” is pretty fundamental to constructing a system.
> And those groupings poison your software by trying to lock in very specific business ideas into software, making it inflexible.
No, the groupings involved in defining a domain do not. There are other levels of analysis in DDD where that might arguably be the case, e.g., the assessment of consistency boundaries, but that's a different discussion.
> If Excel had a "problem solving user" domain and a "business account" domain, etc, it would be terrible software.
No system designed with DDD has multiple distinct domains.
This is very much analogous to failure to use newtype wrappers in Haskell-like languages to differentiate distinct uses of existing types. Same symptoms, same underlying conceptual issue.
Two strings walk into a bar and sit down. The bartender says, "So what'll it be?"
The first string says, "I think I'll have a beer quag fulk boorg jdk^CjfdLk jk3s d#f67howe%^U r89nvy~~owmc63^Dz x.xvcu"
"Please excuse my friend," the second string says, "He isn't null-terminated."
This is so wrong, why not use newname for a new name value?
Being clever like this is exactly why I stay away from C/C++ and other case sensitive languages. They encourage pendantry.