Skip to content

Commit 5b0f4a9

Browse files
committed
Grammar fixes, template method
1 parent 808df54 commit 5b0f4a9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

template-method/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ structure.
1717

1818
## Explanation
1919

20-
Real world example
20+
Real-world example
2121

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.
2425
2526
In plain words
2627

@@ -117,7 +118,7 @@ public class HalflingThief {
117118
}
118119
```
119120

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.
121122

122123
```java
123124
var thief = new HalflingThief(new HitAndRunMethod());
@@ -135,14 +136,14 @@ And finally we show how the halfling thief utilizes the different stealing metho
135136
The Template Method pattern should be used
136137

137138
* 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
139140
* To control subclasses extensions. You can define a template method that calls "hook" operations at specific points, thereby permitting extensions only at those points
140141

141-
## Tutorial
142+
## Tutorials
142143

143144
* [Template-method Pattern Tutorial](https://www.journaldev.com/1763/template-method-design-pattern-in-java)
144145

145-
## Real world examples
146+
## Known uses
146147

147148
* [javax.servlet.GenericServlet.init](https://jakarta.ee/specifications/servlet/4.0/apidocs/javax/servlet/GenericServlet.html#init--):
148149
Method `GenericServlet.init(ServletConfig config)` calls the parameterless method `GenericServlet.init()` which is intended to be overridden in subclasses.

0 commit comments

Comments
 (0)