Extract Specialized Entity
Also known as: Carve Specialized Entity Out of Monolithic Entity
A special case of Extract Class
Motivation
As one step of Extract Bounded Context you’ve found a monolithic domain model. In this you have identified an entity that has become too big. The decision has been made to split it.
If you have an anemic domain model instead of a behavioral rich domain model apply Extract Specialized Anemic Entity instead.
This is often accompanied by Extract Specialized Table.
Mechanics
- Create empty new class in carved-out context
- Add instance field of type new class to the old class
- Copy to-be-moved fields from old to new class with Move Field
- Copy first to-be-moved method to new class with Move Method
- Replace method body in old class with a forward to method in new class
- Step by step replace calls to the method in the old class with calls to the method in the new class
- Delete the implementation in the old class
- Delete now unused fields in old class
- Repeat with other to-be-moved methods
- Remove instance field of type new class in the old class