Android developers probably are familiar with Ceja's Clean Architecture, where use cases are classes that implement the Command Pattern.
Shvets defines the pattern intents as follows:
- Encapsulate a request as an object, thereby letting you parametrize clients with different requests, queue or log requests, and support undoable operations.
- Promote "invocation of a method on an object" to full object status
- An object-oriented callback
I use that approach in order to improve code readability and testability. But, after reading Shvets's Anti-Patterns course, I got confused with his Functional Decomposition Anti-Pattern definition:
- Classes with "function" names such as Calculate_Interest or Display_Table may indicate the existence of this AntiPattern.
- All class attributes are private and used only inside the class.
- Classes with a single action such as a function.
- An incredibly degenerate architecture that completely misses the point of object-oriented architecture.
- Absolutely no leveraging of object-oriented principles such as inheritance and polymorphism. This can be extremely expensive to maintain (if it ever worked in the first place; but never underestimate the ingenuity of an old programmer who's slowly losing the race to technology).
- No way to clearly document (or even explain) how the system works. Class models make absolutely no sense.
- No hope of ever obtaining software reuse.
- Frustration and hopelessness on the part of testers.
How may I am figure out if I am using Functional Decomposition Anti-Pattern instead of Command Pattern?
Execute()
methods.