Comparison
Domain modelvsTransaction script
Domain model
the rule about when an order can be cancelled lives on the order, and there is exactly one copy of it.
An object model of the business in which the objects carry both the data and the rules that operate on it. It pays off when the rules are genuinely complicated and interlocking, because each rule has one home and the model can be tested without any infrastructure. It costs more than a transaction script up front and is the wrong choice for an application whose logic is mostly validation and storage.
Full entry →Transaction script
one method reads the rows, does all the logic and writes them back, and it is four hundred lines long.
Organising business logic as a procedure per use case, working directly against the data. It is the honest right answer for a simple application, and it is what almost every codebase starts as; the failure comes later, when the tenth script needs the same discount rule and copies it. Fowler's original point stands: choose it deliberately for simple logic rather than arriving at it by default.
Full entry →