๐Ÿ”จ DDD (Domain-Driven Design) and Domain Model

564 ๋‹จ์–ดยท3 ๋ถ„ยท์›๋ฌธ(.md)

Overview #

As a Domain-Driven Design developer, I believe we should not only write code but also create an environment where we can efficiently structure and manage the architecture. I think efficient code cannot exist without establishing an overall framework. That's why I decided to study Domain-Driven Design.

What is DDD (Domain-Driven Design)? #

Domain-Driven Design is one of the design methodologies used in software development. This methodology aims to solve business problems and create maintainable software by designing software around the business domain.

Domain-Driven Design focuses software development on terms, concepts, and rules related to the business domain. To achieve this, it introduces the concept of a domain model to clearly express the business domain's concepts and rules and reflect them in the software.

Advantages of DDD

  • Strong connection between business logic and software modeling: Provides a strong connection between the business domain and software modeling.
  • Ease of implementing complex business logic: Provides a suitable environment for implementing complex logic, enhancing readability and maintainability.
  • Use of a common language: Facilitates active communication between developers and domain experts through the use of a common language.
  • Testability: Increases flexibility by modularizing the software system and reducing coupling through domain modeling.

Domain Model #

A domain model expresses the important concepts and rules of a business domain. Software is designed based on this. Through this, developers can analyze system requirements and design the system to meet those requirements.

Domain models are primarily used in Object-Oriented Programming (OOP), modeling domain concepts and rules using object attributes and methods. Additionally, domain models form a domain layer by collecting objects commonly used throughout the system.

  • The domain model is continuously modified according to changes in system requirements and business logic.
  • The modified domain model is applied to the implementation and testing of the software system.
  • Therefore, the domain model plays a crucial role in enhancing the flexibility, maintainability, and scalability of the software system.

Methods for Designing a Good Domain Model

  1. Understand domain knowledge
  2. Analyze requirements
  3. Domain modeling
  4. Validate the domain model
  5. Update the domain model
  6. Document the domain model

Key DDD Terms #

Let's briefly look at the key terms used in DDD. These terms will be covered in more detail in the next post.

  1. Domain: Refers to the problem space or business area.
  2. Domain Model: A model of concepts, rules, and relationships within the domain.
  3. Entity: Refers to an object in the domain model that has a unique identifier.
  4. Value Object: Refers to an object that, unlike an entity, does not have a unique identifier. It is generally immutable and has composite attributes.
  5. Aggregate: Refers to a cluster of related entities and value objects. Consistency must be maintained within an aggregate, and the state of other aggregates cannot be directly changed.
  6. Repository: Plays the role of retrieving or storing the state of domain models from a persistent storage.
  7. Domain Service: Refers to a service that handles domain logic involving multiple entities or value objects.
  8. Factory: A pattern that abstracts object creation, encapsulating complex object instantiation to improve code readability and maintainability.
  9. Event: An object representing a significant occurrence in the domain. Using events can simplify interactions between systems and increase flexibility.

Conclusion #

In this post, we explored the overall concepts and terms of DDD. To delve deeper, I will not be satisfied with this and will upload more posts.

Back-End/ddd/ddd.md