Review for Quiz 4
Decorator, Strategy, Observer, and Data Pull Design Patterns
It is recommended to review these topics:
- Why and how to make a function decorator
- When to use the Strategy pattern (and how)
- When to use Observer versus Data Pull (and how)
Iterator and Comparable
It is recommended to review this table:
| Iterable | Iterator | |
|---|---|---|
| Protocol's required methods | __iter__(self) -> Iterator[T]: returns an iterator | __next__(self) -> T: returns the next element or raises StopIteration __iter__(self) -> Iterator[T] : returns itself |
abc interface's required methods | __iter__(self) -> Iterator[T] (same as protocol) | __next__(self) -> T (same as protocol) not __iter__(self) -> Iterator[T] because it's aleady there |
- Implementing the Comparable protocol
- Checking for inconsistencies between implemented Comparable methods
- Rules for using
<,>, etc.