Appendix C. Tactical Refactorings That Support Strategic Refactorings
Strategic refactorings are still big and have to be divided into smaller steps. In this appendix we present these smaller steps—tactical refactorings that support the strategic ones. A supporting tactical refactoring is always carried out as part of a strategic refactoring.
When extracting a bounded context, you can encounter different situations:
-
An anemic domain model. Then Extract Specialized Anemic Entity and Extract Specialized Service, can help you.
-
A domain model with rich behavior. This can be split with Extract Specialized Entity and with Extract Specialized Service.
-
A monolithic data model. Tackle it with Extract Specialized Table.
Extract Specialized Service
Also known as: Carve Specialized Anemic Service Out of Monolithic Service
A special case of Extract Class [Fowler 2019, p. 182]
Motivation
As one step of Extract Bounded Context, you’ve found a domain service that has become too big. Its functionality belongs partly in the bounded context that is extracted. The decision has been made to split it.
Mechanics
-
Create an empty new class in the carved-out context.
-
Add an instance field of type new class to the old class.
-
Copy the first to-be-moved method to the new class with Move Method [Fowler 2019, p. 198].
-
Replace the method body in the old class with a forward to the method in ...