Skip to content

Commit c384ce9

Browse files
authored
Update readme.md
Add comments on the template pattern
1 parent 610d135 commit c384ce9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

chapter08_template/readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# Chapter 8: Template design pattern
22

33
> **Template Method**: Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.
4+
5+
The template design pattern is widely used in frameworks such as Django, providing base classes which can be extended to provide required methods.
6+
7+
Variants of the template pattern are found throughout the Python object model, for instance iterable sorting is implemented by running the *less than* (`__lt__`) comparison operator between items in the collection. In this sense the [list sorting algorithm](https://docs.python.org/3/howto/sorting.html#odd-and-ends) is a partial implementation of sort, delegating the comparison behavior to individual objects.

0 commit comments

Comments
 (0)