Extract Service 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. Can it work only on parameters without using fields from the class? Then this refactoring is right, otherwise Extract Entity from Smart UI might fit better.
- Apply Extract Class and move the business logic method into the newly created service.