Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this really DDD?

Tags:

I am 80% sure I should not be asking this question because it might come across as negative and I mean no disrespect to anyone, especially the author of this book. I have seen several posts recommending this book and its companion project. I have not read the book, but I have spent a few hours today studying the project. And while it does look very complete, I am having a very hard time with how much the details of various things are scattered around. I am struggling in my own designs with how much I have to change if an entity changes, and this project does not make me very comfortable as a solution.

For example, there is a Employee object that inherits from a Person. Person has a constructor with first-name, last-name, etc. and therefore, so does Employee. Private to Employee are members for first name, last name, plus public properties for the same.

There is an EmployeeFactory that knows about both Employee and Person properties, as well as the SQL column names (to pull values from a reader).

There is an EmployeeRepository with unimplemented PersistNewItem and PersistUpdatedItem methods that I suspect, if implemented, would build SQL for INSERT and UPDATE statements like I see in CompanyRepository. These write the properties to strings to build the SQL.

There is a 'Data Contract' PersonContract with the same private members and public properties as Person, and an EmployeeContract that inherits from PersonContract like Employee does Person, with public properties mirroring the entities.

There is a static 'Converter' class with static methods that map entities to Contracts, including

EmployeeContract ToEmployeeContract(Employee employee)  

which copies the fields from one to the other, including Person fields. There may be a companion method that goes the other way - not sure.

I think there are unit tests too.

In all I count 5-10 classes, methods, and constructors with detailed knowledge about entity properties. Perhaps they're auto-generated - not sure. If I needed to add a 'Salutation' or other property to Person, I would have to adjust all of these classes/methods? I'm sure I'd forget something.

Again, I mean no disrespect and this seems to be a very thorough, detailed example for the book. Is this how DDD is done?

like image 710
n8wrl Avatar asked Apr 21 '09 20:04

n8wrl


People also ask

Is DDD really useful?

Domain-driven design (DDD) is a useful approach that provides excellent guidelines for modeling and building systems, but it is a means to an end, not an end in itself. While the concepts are valid, you lose a lot if you limit yourself to using them only: There actually is a life beyond DDD.

What is the point of DDD?

The strategic aspect of DDD aligns software development teams' efforts with the interests of the business. It helps when deciding what to focus on, usually by identifying one core domain. This may be a specific area of business or even a specific slice that's critical.

Is DDD an OOP?

OOP + Ubiquitous Language = DDD Even though they share similar practices, DDD is more than what OOP tries to solve. Reason being, even though we might be wiring our code from a technical perspective, we are still solving the problem at an incrementally lower level.

What is DDD simplified?

Domain-driven design is the idea of solving problems of the organization through code. The business goal is important to the business users, with a clear interface and functions. This way, the microservice can run independently from other microservices.


1 Answers

Domain Driven Design is really simple. It says: make your Model classes mirror the real world. So if you have Employees, have an Employee class and make sure it contains the properties that give it its 'Employee-ness'.

The question you are asking is NOT about DDD, but rather about class architecture in general. I think you're correct to question some of the decisions about the classes you're looking at, but it's not related to DDD specifically. It's more related to OOP programming design patterns in general.

like image 144
RibaldEddie Avatar answered Oct 06 '22 23:10

RibaldEddie