This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Which the same way to solve a problem | |
//Template Method uses Inheritance | |
//Strategy uses Composition/Delegation | |
abstract class TemplateMethod{ | |
public final void execute() { | |
doFirstThing(); | |
doSecondthing(); | |
} | |
//modifier can be public, private, protected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class AbstractDocumentGenerator{ | |
//THIS IS TEMPLATE METHOD | |
public final File generate() { | |
Document defaultDocument = prepareDocumentByDefault(); | |
Document refinedDocument = redefineDocument(defaultDocument); | |
String templatePath = getTemplatePath(); | |
String outputName = getOutputName(); | |
return DocFactory.generate(refinedDocument, templatePath, outputName); | |
} |
NewerOlder