For example, we have two domain objects: Cell and Body (as in human cell and body).
The Body class is just a collection of Cells, e.g.
class Body
{
IList<Cell> cells;
public void AddCell(Cell c) { ... }
public void RemoveCell(Cell c) { ... }
}
The Cell has a Split method, which internally creates a clone of itself, e.g.
Class Cell
{
public Cell Split()
{
Cell newCell = new Cell();
// Copy this cell's properties into the new cell.
return Cell;
}
}
Now, in DDD when the cell splits should:
Thanks in advance.
Domain-Driven Design(DDD) is a collection of principles and patterns that help developers craft elegant object systems. Properly applied it can lead to software abstractions called domain models. These models encapsulate complex business logic, closing the gap between business reality and code.
Aggregates are a design pattern that play a big role in domain-driven development. In many systems, the relationships between entities can become so interwoven that attempting to eager-load an entity and all of its related entities from persistence results in attempting to download the entire database.
In domain-driven design, an entity is a representation of an object in the domain. It is defined by its identity, rather than its attributes. It encapsulates the state of that object through its attributes, including the aggregation of other entities, and it defines any operations that might be performed on the entity.
Domain-driven design (DDD) advocates modeling based on the reality of business as relevant to your use cases. In the context of building applications, DDD talks about problems as domains.
I'd think that the Body would simply call the splitCell() on the Cell. Then the Body can do what it wants with the new Cell - add to itself, consume it, throw it away, whatever. The Body contains the Cell anyway.
In DDD, it often depends on, well, the domain. Here, the example - and thus the domain - seems a bit weird but I think I would go for a SplitCell
method on Body
.
Although it's not very clear to me what the cell splitting means, and what should trigger this action, I guess the body is responsible for splitting its cells. I would be more comfortable with a Regenerate
method, or something like that, on the Body
, that splits internal cells by calling the Split
method on each ones.
Ok, this example is definitively bizarre...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With