4 ms·
The problem isn't controllers. Controller are responsible for mediating the behavior presented to external actors, not defining complex "business" logic. Comp
by kastephens 14y ago
The problem isn't controllers. Controller are responsible for mediating the behavior presented to external actors, not defining complex "business" logic.
Complex logic interacts with complex object graphs, not individual models. Therefore, complex logic does not belong in models or controllers (or views). Complex logic belongs in instantated objects (not modules) that represent complex logic. This style may also be known as the "Strategy" Design Pattern.
Strategy objects can have state during their activities, this is why they should be instantiated.
Strategy objects simplify testing because they can be connected with any object graph that presents the same interfaces as the target object graphs.
This leads to interchangable Strategy objects that represent generic behavior which can be applied to actual, simulated or speculative object graphs.