Skip to content

Commit 8fdf88c

Browse files
committed
Markdown updates
1 parent 7dd4bc2 commit 8fdf88c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

chapter09_iterator/readme.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
# Chapter 8: Iterator design pattern
1+
# Chapter 9: Iterator and Composite design patterns
22

3-
> **Template Method**: provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
3+
> **Iterator Method**: provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
44
55
Python requires only the `__iter__()` method to be implemented for an object to return `True` to `isinstance(obj, Iterable)`, however if an object implements just the `__getitem__()` without `__iter__` method then it will work as an iterable!
6+
7+
> **Composite Pattern**: allows you to compose objects into tree structures to represent whole-part hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
8+
9+
A pythonic alternative would be to:
10+
11+
```python
12+
try:
13+
composition_method()
14+
except CompositionMethodError:
15+
individual_method()
16+
```

0 commit comments

Comments
 (0)