Skip to content

Domain Core Module

Business Logic

Business logic that cannot fit in the aggregate. Used when multiple aggregates required in business logic can interact with other domain services.

Use or need of common domain module.

  • BaseEntity
  • AggregateRoot
  • BaseId(e.g: V.O)

Part I.

  • Aggregate Root
  • Entities
  • Value Object

Part II

  • Exception classes
  • Domain Events
  • Domain Service

Why not use Lombok

Lombok is a Java library that helps to reduce boilerplate code in Java classes, such as constructors, getters, and setters. While it can be useful, some developers prefer not to use it due to concerns about code readability and maintainability.

Why no?

NOT: For the core logic, is not recommended. It is a bad idea use any framework that autogenare code, becasue, you need to see code directly, maybe add any validation.

πŸ•ΉοΈ Plugins to auto-generate builder without losing control

Dependencies

pom.xml
1
2
3
4
<dependency>
    <groupId>lg5.common</groupId>
    <artifactId>lg5-common-domain</artifactId>
</dependency>

Unit Test to Use Case

If you need to create tests (only unit test for this module), you can add the following dependency:

pom.xml
1
2
3
4
5
6
<!--unit test -->
<dependency>
    <groupId>com.lg5.jvm</groupId>
    <artifactId>lg5-jvm-unit-test</artifactId>
    <scope>test</scope>
</dependency>

Structure Project

com.blanksystem.blank.service
└── domain/
    β”œβ”€β”€ BlankDomainService.java
    β”œβ”€β”€ BlankDomainServiceImpl.java
    β”œβ”€β”€ entity/
    β”‚  └── Blank.java
    β”œβ”€β”€ event/
    β”‚  β”œβ”€β”€ BlankCreatedEvent.java
    β”‚  └── BlankEvent.java
    β”œβ”€β”€ exception/
    β”‚  β”œβ”€β”€ BlankDomainException.java
    β”‚  └── BlankNotFoundException.java
    └── valueobject/
       └── BlankId.java