|
|
|
|
|
by twhitmore
1520 days ago
|
|
The interesting thing is that DDD identifies & distils most (not all) of the patterns I'd seen used or had to crystallize myself, over the past say 15 years of application development. Key aspects like building a domain (business) layer, separating this from the DAO layer, speaking domain terminology, clearly defining entity identity (it's not a hash/ equals on Customer Name), encapsulating meaningful domain operations into domain entity & value types, orchestrating fine-grained data into larger aggregates, and orchestrating major business processes as 'services' are all great patterns. What kind of pitfalls or gotcha moments are you running into? I would think the patterns above should suffice for business applications ranging up to moderately complex. |
|
All the examples out there use UoW frameworks like Hibernate that fire lots of arcane magic at the problem that is near impossible to understand, show to be correct (even in an informal way), debug, ... The fact that you need "magic" at all is a huge anti-pattern to me. It just shows that the concept is flawed.
My own solution was to keep no entity state in memory and translate everything into DB updates immediately. Use DB transactions where needed. You'll need another layer of code to abstract those higher-level DB operations so your domain code isn't littered with DB accesses, but apart from the extra lines-of-code the whole thing becomes very clean IMHO. Problem is, you won't find this solution described anywhere, and you are completely on your own.