Template Pattern
Template Pattern A Template Pattern says that “just define the skeleton of a function in an operation, deferring some steps to its subclasses”. Benefits: It is very common technique for reusing the code.This is only the main benefit of it. Usage: It is used when the common behavior among sub-classes should be moved to a single common class by avoiding the duplication. UML for Template Pattern: Implementation of Template Pattern: Step 1: Create a Game abstract class. / /This is an abstract class. pub lic abstrac t class Game { abs tract void init ialize(); abstract v oid start () ; abstractvoid end () ; publicfinalvoid play () { // initialize the game initialize () ; // start game start () ; // end game end () ; } } // End of the Game abstract class. Step 2: Create a Chess class that will extend Game abstract class for giving the definition to its method. public class Chess extends Game { @Ov erride void initi alize() { S ystem.out.p rintln ( ...