Skip to content

Lidiadev/ddd-legacy-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Domain-Driven Design - sample to showcase how to work with legacy projects

Project Details

The sample project is a Package Delivery System which keeps track of packages for delivery with the following features:

  • create delivery: select customer and address
  • edit package: select products
  • send package to customer.

The Package Delivery System is a desktop application written in WPF. It uses Dapper to execute SQL queries.

The Anti-Corruption Layer

The anti-corruption layer is an adapter layer which handles the conversation between the legacy code and the bubble context.

Benefits:

  • combines the benefits of a full rewrite with gradual refactoring: working on a greenfield domain model while still delivering business value.

Considerations:

  • the anti-corruption layer is an additional service that must be managed, maintained and scaled
  • it may add latency.

How to refactor

  • introduce a bubble context with the new domain model with proper encapsulation
  • create the anti-corruption layer to handle the conversation between the legacy code and the bubble context (through repositories in this case)

anticorruption layer

  • promote the anti-corruption layer to the synchronizing anticorruption layer which resides in its own bounded context (create a separate DB for the bubble context)

sync layer

For the current sample, the following approach has been used:

  • created triggers for both databases to monitor changes
  • only monitored the data the context own
  • added a new table synchronization in order to reduce the pressure on the domain tables
  • the synchronization between the bubble context DB and the legacy DB is done asynchronously
  • the bubble has been decoupled from ACL.

Branches

  • Initial - the initial branch contains the legacy project.
  • Master - the master branch will contain the code after refactoring.

About

Domain-Driven Design - working with legacy projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published