From f51be64faf09039e6bae803b76ddd594180a819d Mon Sep 17 00:00:00 2001 From: Petrutiu Mihai Date: Thu, 14 Jul 2016 17:00:03 +0300 Subject: [PATCH 1/4] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 1265c22..7ab175b 100644 --- a/README.md +++ b/README.md @@ -415,6 +415,14 @@ The strategy pattern defines a family of algorithms, encapsulates each algorithm 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. Template pattern works using 'the Hollywood principle' from the base class point of view: 'Don't call us, we'll call you' + +Class diagram: + +![alt text](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/BehavioralPatternsDiagrams/TemplateMethodPattern/TemplateMethodPatternClassDiagram.PNG "Template method pattern class diagram") + +Sequence diagram: + +![alt text](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/BehavioralPatternsDiagrams/TemplateMethodPattern/TemplateMethodPatternSequenceDiagram.PNG "Template method pattern sequence diagram") ### b. When to use Template method pattern * 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. From 1f22109ebde34cc1bc8977f86cac0c693abc22b9 Mon Sep 17 00:00:00 2001 From: Petrutiu Mihai Date: Thu, 14 Jul 2016 17:01:28 +0300 Subject: [PATCH 2/4] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7ab175b..ff4d714 100644 --- a/README.md +++ b/README.md @@ -417,6 +417,9 @@ defering some steps to subclasses. It lets one redefine certain steps of an algo Template pattern works using 'the Hollywood principle' from the base class point of view: 'Don't call us, we'll call you' Class diagram: +legend: +# is for protected method +Italic is for abstract method ![alt text](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/BehavioralPatternsDiagrams/TemplateMethodPattern/TemplateMethodPatternClassDiagram.PNG "Template method pattern class diagram") From fc90a107e09cc977b4479bce58bb163e27130009 Mon Sep 17 00:00:00 2001 From: Petrutiu Mihai Date: Thu, 14 Jul 2016 17:02:56 +0300 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff4d714..3bce549 100644 --- a/README.md +++ b/README.md @@ -418,7 +418,7 @@ Template pattern works using 'the Hollywood principle' from the base class point Class diagram: legend: -# is for protected method +\# is for protected method Italic is for abstract method ![alt text](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/BehavioralPatternsDiagrams/TemplateMethodPattern/TemplateMethodPatternClassDiagram.PNG "Template method pattern class diagram") From 1548beb8f6779a01770e69e72b88fb535f39d0df Mon Sep 17 00:00:00 2001 From: Petrutiu Mihai Date: Thu, 14 Jul 2016 17:03:18 +0300 Subject: [PATCH 4/4] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3bce549..c06ac32 100644 --- a/README.md +++ b/README.md @@ -418,8 +418,8 @@ Template pattern works using 'the Hollywood principle' from the base class point Class diagram: legend: -\# is for protected method -Italic is for abstract method +* \# is for protected method +* Italic is for abstract method ![alt text](https://github.com/MihaiTheCoder/BehavioralPatterns/blob/master/BehavioralPatternsDiagrams/TemplateMethodPattern/TemplateMethodPatternClassDiagram.PNG "Template method pattern class diagram")