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: template-method/README.md
+8-7Lines changed: 8 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -17,10 +17,11 @@ structure.
17
17
18
18
## Explanation
19
19
20
-
Realworld example
20
+
Real-world example
21
21
22
-
> The general steps in stealing an item are the same. First you pick the target, next you confuse
23
-
> him somehow and finally you steal the item. However there are many ways to implement these steps.
22
+
> The general steps in stealing an item are the same. First, you pick the target, next you confuse
23
+
> him somehow and finally, you steal the item. However, there are many ways to implement these
24
+
> steps.
24
25
25
26
In plain words
26
27
@@ -117,7 +118,7 @@ public class HalflingThief {
117
118
}
118
119
```
119
120
120
-
And finally we show how the halfling thief utilizes the different stealing methods.
121
+
And finally, we show how the halfling thief utilizes the different stealing methods.
121
122
122
123
```java
123
124
var thief =newHalflingThief(newHitAndRunMethod());
@@ -135,14 +136,14 @@ And finally we show how the halfling thief utilizes the different stealing metho
135
136
The Template Method pattern should be used
136
137
137
138
* To implement the invariant parts of an algorithm once and leave it up to subclasses to implement the behavior that can vary
138
-
* When common behavior among subclasses should be factored and localized in a common class to avoid code duplication. This is good example of "refactoring to generalize" as described by Opdyke and Johnson. You first identify the differences in the existing code and then separate the differences into new operations. Finally, you replace the differing code with a template method that calls one of these new operations
139
+
* When common behavior among subclasses should be factored and localized in a common class to avoid code duplication. This is a good example of "refactoring to generalize" as described by Opdyke and Johnson. You first identify the differences in the existing code and then separate the differences into new operations. Finally, you replace the differing code with a template method that calls one of these new operations
139
140
* To control subclasses extensions. You can define a template method that calls "hook" operations at specific points, thereby permitting extensions only at those points
Method `GenericServlet.init(ServletConfig config)` calls the parameterless method `GenericServlet.init()` which is intended to be overridden in subclasses.
0 commit comments