Tagged “Template-Method”
2 articles with this tag.
- Strategy vs State vs Template MethodThree patterns that all vary behaviour: Strategy swaps a whole algorithm by composition, State swaps behaviour as an object's lifecycle changes, and Template Method varies steps by inheritance. Side-by-side code, the deciding questions and how to choose.
- Template MethodDefine the skeleton of an algorithm in a base class and let subclasses fill in specific steps. A runnable Java 21 data-import pipeline with abstract steps and hooks, the Hollywood Principle, Spring's JdbcTemplate and callbacks, and when to prefer Strategy and composition.