Skip to content

Commit faa2ce3

Browse files
authored
Updated comments on the patterns
1 parent c384ce9 commit faa2ce3

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

chapter05_singleton/readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
> **Singleton**: ensures a class has only one instance, and provides a global point of access to it.
44
5-
Based this [stackoverflow post](https://stackoverflow.com/questions/6760685/creating-a-singleton-in-python?noredirect=1&lq=1).
5+
My implementation is based this [stackoverflow post](https://stackoverflow.com/questions/6760685/creating-a-singleton-in-python?noredirect=1&lq=1).

chapter06_command/readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
> **Command**: Encapsulates a request as an object, thereby letting you parameterise clients with different requests, queue or log requests, and support undoable operations.
44
5+
## Use in Python
6+
57
[Threading](https://docs.python.org/3/library/threading.html) In the Python standard library follows the command design pattern: The _Client_ is the main thread and the _receiver_ is the target thread. The _Command_ is a callable Python object which is executed by calling its `__call__()` method. The _Invoker_ is the `Thread` instance and its `run()` method is equivalent to calling _execute_ in the Command pattern. `Thread`'s `run` method can be overridden in subclasses to customise the functionality beyond simply providing a function and input `args` and `kwargs`.

chapter07_adapter_facade/readme.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22

33
> **Adapter**: Converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
44
5+
Compiled C modules in Python could be seen as examples of the adapter pattern: the Python implementation provides an interface for python code to work with the incompatible underlying C code.
6+
57
> **Façade**: Provides a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.
8+
9+
The [pathlib](https://github.com/python/cpython/blob/main/Lib/pathlib.py) Python library provides a simplified high-level cross-platform interface to methods and attributes from the `os`, `sys`, `io` and other modules.
10+

0 commit comments

Comments
 (0)