Java Command and Template Method Patterns: Encapsulate Requests and Algorithms
Maya's shop has grown past the checkout. Two admin jobs now eat her staff's mornings. The first is the product-description editor: a member of staff rewrites a book's description, a slip deletes a paragraph, and there is no way back — the old text is gone, and the only fix is retyping it from memory. The second is the nightly supplier import: two suppliers send catalogues in different formats — one comma-separated lines, the other JSON — and every format has its own copy of the same four steps: open, parse, check, store. A fix to the checking step has to be made twice, and last month it was made once. That is the problem. Post 1 asked what varies? Post 2, Java Singleton Pattern: Enum, Lazy Holder & Double-Checked Locking Explained , asked how many? Post 3, Java Factory Pattern: Factory Method vs Abstract Factory With Examples , asked who decides which object gets created? Post 4, Java Builder Pattern: Build Complex Objects Without Telescoping Constructors , asked h...