Entities
Learn what an entity is and how to implement it in the context of Domain Driven Design.
Modeling a domain can be a difficult task. Once the whole model is done, the next step is to move on to the code. The best approach to translate the domain model into code is to use Object-Oriented Programming. Thinking about the interaction between objects is easy. To implement this approach Domain Driven Design defines a number of artifacts that allow technical experts to represent a domain model in the code.
What is model driven design?
Model Driven Design says that a software solution should be implemented based on the analysis of models. Remember that a model is an abstraction and representation of something from the real world for the sake of understanding it. Once a domain is modeled, it is possible to begin the implementation of software.
Beyond the Model Driven Design methodology, the Object Management Group (OMG) has created a conceptual framework called Model Driven Architecture (MDA); it provides guidelines for structuring software specifications that are expressed as models. It covers the complete development lifecycle in analysis, design, programming, testing, deployments, and maintenance stages. MDA has three models:
- Computation Independent Model (CIM): focused on the domain model.
- Platform Independent Model (PIM): focused on a general platform where a solution will be deployed.
- Platform Specific Model (PSM): focused on a specific platform where a solution will be deployed.
What is an entity in the DDD world?
According to Model Driven Design, DDD has some tactical patterns to represent a model. There are three possible domain objects to implement business logic: Entities, Value Objects, and Aggregates.
In the DDD context, an entity represents something that is involved in a business process. For example, in the context of a bank, some entities may be Account, Credit Card, Customer, or Transaction. An entity has well-defined attributes and domain behavior. Additionally, it is identified by identification such as an ID or a Key, which implies that attribute values may change whenever needed. That is why this domain object is mutable. Attribute values can change without affecting the identification of an object.
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy