Domain Driven Design

Core Principles

  1. Focus on the Domain
  2. Ubiquitous Language
  3. Bounded Contexts
  4. Modeling the Domain

Development flow:

  1. Define the domain.
  2. Define the Ubiquitous Language. (Dictionary)
    1. List the Nouns (Entities/Values) and Verbs (Actions) that are essential for this system
  3. Pick the Aggregate Root. ("boss" object that controls consistency)
    1. When some event happen, always access this.
  4. Create the Aggregate Root Model class.
    1. Not using JPA annotation. (@Table@Column@Id)
    2. No lombok (except for @AllArgsConstructor).
    3. No created_at, update_at.
    4. Still use UUID.
    5. One field is referencing child entity id.
    6. Set getter if needed.
    7. final for the fields.
  5. Add the behaviour in Aggregate Root.
  6. Create Factory method for Aggregate Root.
  7. Create Repository.
  8. Go to infrastructure folder, create Aggregate Root entity class, ****which is entity version.
    1. Use JPA annotation. (@Table@Column@Id)
    2. Use lombok (except for @AllArgsConstructor).
    3. Use created_at, update_at.