Quantcast
Channel: JavaPins - Stories tagged with design pattern
Viewing all articles
Browse latest Browse all 25

Template Method Design Pattern in Java

$
0
0
Template Method design pattern 01 Standardize the skeleton of an algorithm in a base class “template” method Common implementations of individual steps are defined in the base class Steps requiring peculiar implementations are “placeholders” in base class Derived classes can override placeholder methods Derived classes can override implemented methods Derived classes can override and “call back to” base class methods 02 abstract class Generalization { // 1. Standardize the skeleton of an algorithm in a "template" method public void findSolution() { stepOne(); stepTwo(); stepThr(); stepFor(); } // 2. Common implementations of individual steps are defined in base class protected void ste
Pin it

Viewing all articles
Browse latest Browse all 25

Trending Articles