Extract Entity from Smart UI

Special Case of Separate Domain from Presentation

Motivation

Smart UI is a pattern (in DDD considered an “anti-pattern,” see [Evans2004, p. 76]) that mixes up UI code and business logic. This refactoring helps to separate the two concerns.

Mechanics

  • In the smart UI class separate the business logic from the UI logic with Extract Method.
  • Examine the extracted business logic method. Does it work on fields fom the class? Then this refactoring is right, if it works only on its parameters, Extract Service from Smart UI might fit better.
  • Apply Extract Class and move the business logic and business data into the newly created entity.

Example(s)