You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: BehavioralPatterns/TemplateMethod/README.md
+17-13Lines changed: 17 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,20 @@ The Template Method pattern suggests to break down an alogirthm into a series of
20
20
21
21
The **template method** controls how subclasses redefine a behavior. This is also referred to as *inversion of control* because subclasses do no longer control how the behavior of a parent class redefined.
22
22
23
+
## Common Structure
24
+
25
+

26
+
27
+
* AbstractClass (CaffeineBeverage)
28
+
* defines abstract primitive operations that concrete subclasses define to implement steps of an algorithm
29
+
* implements a template method defining the skeleton of an algorithm. The template method calls primitive operations as well as operations defined in AbstractClass or those of other objects.
30
+
* ConcreteClass (Tea, Coffee)
31
+
* implements the primitive operations ot carry out subclass-specific steps of the algorithm
32
+
33
+
## Collaborations
34
+
35
+
* ConcreteClass relies on AbstractClass to implement the invariant steps of the algorithm.
36
+
23
37
## Benefits
24
38
25
39
* Helps to eliminate code duplication
@@ -34,17 +48,7 @@ The **template method** controls how subclasses redefine a behavior. This is als
34
48
* When subclasses should be able to extend the base algorithm without altering its structure.
35
49
* When you have several classes that do similar things with only minor differences. When you alter one of the classes, you have to change others as well (e.g. HTML/PDF/CSV Generator follows the same data processing steps before generating the specific file format).
36
50
37
-
## Common Structure
38
-
39
-

40
-
41
-
* AbstractClass (CaffeineBeverage)
42
-
* defines abstract primitive operations that concrete subclasses define to implement steps of an algorithm
43
-
* implements a template method defining the skeleton of an algorithm. The template method calls primitive operations as well as operations defined in AbstractClass or those of other objects.
44
-
* ConcreteClass (Tea, Coffee)
45
-
* implements the primitive operations ot carry out subclass-specific steps of the algorithm
0 commit comments