Update README.md

This commit is contained in:
Petrutiu Mihai
2016-07-14 16:42:01 +03:00
committed by GitHub
parent 23c932e8d2
commit ba5bfb7f6a

View File

@@ -33,7 +33,7 @@ Patterns described:
[8. Strategy pattern](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/README.md#8-strategy-pattern) [8. Strategy pattern](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/README.md#8-strategy-pattern)
[9. Template pattern](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/README.md#9-template-pattern) [9. Template method pattern](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/README.md#9-template-pattern)
[10 Visitor pattern](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/README.md#10-visitor-pattern) [10 Visitor pattern](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/README.md#10-visitor-pattern)
@@ -408,14 +408,14 @@ The strategy pattern defines a family of algorithms, encapsulates each algorithm
* Motivational example: ArrangeInterview.ArrangeInterviewMotivationalExample * Motivational example: ArrangeInterview.ArrangeInterviewMotivationalExample
9. Template pattern 9. Template method pattern
------------------ ------------------
### a. Pattern description ### a. Pattern description
In software engineering, the template method pattern is a behavioral design pattern that defines the program skeleton of an algorithm in an operation, In software engineering, the template method pattern is a behavioral design pattern that defines the program skeleton of an algorithm in an operation,
defering some steps to subclasses. It lets one redefine certain steps of an algorithm without changing the algorithm's structure. defering some steps to subclasses. It lets one redefine certain steps of an algorithm without changing the algorithm's structure.
Template pattern works using 'the Hollywood principle' from the base class point of view: 'Don't call us, we'll call you' Template pattern works using 'the Hollywood principle' from the base class point of view: 'Don't call us, we'll call you'
### b. When to use Template pattern ### b. When to use Template method pattern
* Let subclasses implement (through method overriding) behavior that can vary. * Let subclasses implement (through method overriding) behavior that can vary.
* Avoid duplication in the code: the general workflow structure is implemented once in the abstract class's algorithm, and necessary variations are implemented in each of the subclasses. * Avoid duplication in the code: the general workflow structure is implemented once in the abstract class's algorithm, and necessary variations are implemented in each of the subclasses.
* Control at what point(s) subclassing is allowed. As opposed to a simple polymorphic override, where the base method would be entirely rewritten allowing radical change to the workflow, only the specific details of the workflow are allowed to change. * Control at what point(s) subclassing is allowed. As opposed to a simple polymorphic override, where the base method would be entirely rewritten allowing radical change to the workflow, only the specific details of the workflow are allowed to change.