Skip to content

DDD Training repository containing the base application implemented during the training with DDD, hexagonal architecture and CQRS

Notifications You must be signed in to change notification settings

Gepardec/ddd-training

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DDD Training

This repository holds a example of a service implementing DDD and CQRS, and is used to get a glimpse into DDD with CQRS. This example is based on use cases I experienced working on projects in the public austrian social insurance.

Content of the training

1. Design the software

We will talk about the use of DDD and the process necessary when designing a DDD based application.

  • How important is ubiquitous language?

  • Where to handle state changes?

  • To recognize business is important not technology

2. DDD Models

We will discuss the DDD models which are already implement, their usage and why they have been implemented as they are.

  • What is an aggregate root

  • What is a value model

  • State change handling within domain models

What are we going to implement?

We will implement

  1. Domain Logic which handle state changes

  2. Business validation on state changes

  3. Translator method which translate between representations

3. Domain events

We will discuss domain events, why we need them, how to implement them, and how to notify registered observers within an Jakarta EE environment.

  • What is a domain event for

  • Why using domain events

  • What data is necessary within a domain event

What are we going to implement?

We will implement

  1. Domain events which represent state changes of importance

  2. the creation and registration of domain events

  3. the observers of domain events

4. Hexagonal architecture

We will discuss the hexagonal architecture and how it play with DDD.

  • What is the architecture for

  • How to realize such an architecture in an application

  • What are the advantages of the hexagonal architecture

5. CQRS

We will discuss the segregation of commands and queries and use-cases.

  • What is CQRS for

  • why segregating commands and queries

  • what are use cases for

What we going to implement?

We will implement

  1. Repositories

  2. Use Cases (CommandHandler and QueryHandler)

  3. Validators for complex validation of domain models

Business Rules

Leistungsfall

Created

  1. Cannot be created if

    • one already exists with the Nummer

    • one already exists for an VSNR in state NEW.

If one of the rules is broken, then the execution must fail with an exception.

State transitions

  1. Can only be marked STORNIERT, when marked as

    • NEW

    • ANWEISUNG_FREIGEGEBEN

  2. Can only be marked ANWEISUNG_FREIGEGEBEN, when marked as

    • NEW

  3. Can only be marked ANGEWIESEN, when marked as

    • ANWEISUNG_FREIGEGEBEN

  4. Can only be marked ABGELEHNT with an explanation (at least 50 characters) and when marked as

    • NEW

    • ANWEISUNG_FREIGEGEBEN

  5. Must have set angeiwesenAm when marked as ANGEWIESEN

If one of the rules is broken, then state transition must not take place and the execution must fail with an error.

Events

  1. Must notify about state transition

Each observer must be notified within the transaction.

Gesamtleistung

Adding Einzelleistungen

  1. Can only have 5 Einzelleistungen

  2. Max sum netto is 100.00

  3. Max sum brutto is 120.00

If one of the rules is broken, then the Einzelleistung must not be added but ignored.

Events

  1. Must notify if an invalid Einzelleistung was tried to be added, after the transaction completed.

Einzelleistung

  1. Max netto is 100.00

  2. Max MWST is 20.00

The must not be an instance of Einzelleistung which breaks this rules. If one is tried to be created invalidly, then the execution must fail with and exception.

About

DDD Training repository containing the base application implemented during the training with DDD, hexagonal architecture and CQRS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published