Extract Specialized Service

A special case of Extract Class

Motivation

As one step of Carve Out Bounded Context (out of Monolith) you’ve found a domain service that has become too big. The decision has been made to split it.

Mechanics

  • Create empty new class in carved-out context
  • Add instance field of type new class to the old class
  • Copy first to-be-moved method to new class => 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
  • Repeat with other to-be-moved methods
  • Remove instance field of type new class in the old class

Example(s)