Skip to content

Commit 67842ac

Browse files
authored
Update readme.md
1 parent 7c51e67 commit 67842ac

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

chapter07_adapter_facade/readme.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
# Chapter 7: Adapter and Facade design patterns
22

3-
I find myself using the adapter and facade patterns a lot when refactoring existing code. I know how I want it to work
4-
and I know how it works now, but I don't have time _right now_ to fix it, so I add an adapter or facade to give it a clean
5-
interface and I only change the underlying code if I need to make significant changes to the underlying implementation.
6-
73
> **Adapter**: Converts the interface of a class into another interface the clients expect. Adapter lets classes work
84
> together that couldn't otherwise because of incompatible interfaces.
95
106
Compiled C modules in Python could be seen as examples of the adapter pattern: the Python implementation provides an
117
interface for python code to work with the incompatible underlying C code.
128

9+
I find the adapter pattern useful when using external libraries like skipy spatial to support my own code.
10+
I want features from the external library but I want to use it with my own objects and the library api doesnt
11+
exactly fit my own. I write a small adapter to make the external library feel right and work well with my own
12+
objects.
13+
1314
> **Facade**: Provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level
1415
> interface that makes the subsystem easier to use.
1516
17+
I also find myself using the adapter and facade patterns a lot when refactoring existing code. I know how I want it to work
18+
and I know how it works now, but I don't have time _right now_ to fix it, so I add an adapter or facade to give it a clean
19+
interface and I make a plan to change the underlying code when it suits me.
20+
1621
The [pathlib](https://github.com/python/cpython/blob/main/Lib/pathlib.py) Python library provides a simplified
1722
high-level cross-platform interface to methods and attributes from the `os`, `sys`, `io` and other modules.
1823

0 commit comments

Comments
 (0)