Skip to content

Commit 2a45514

Browse files
committed
updates
1 parent 6d900c5 commit 2a45514

File tree

7 files changed

+63
-69
lines changed

7 files changed

+63
-69
lines changed

adapter/README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Adapter Design Pattern
22

3+
## Videos
4+
5+
Section | Video Links
6+
-|-
7+
Adapter Overview | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/16399566/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Adapter Overview"><img src="/img/udemy_btn_sm.gif" alt="Adapter Overview"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/030ih2rpOhY" target="_blank" title="Adapter Overview"><img src="/img/yt_btn_sm.gif" alt="Adapter Overview"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Adapter Overview"><img src="/img/skillshare_btn_sm.gif" alt="Adapter Overview"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
8+
Adapter Use Case | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25400220/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Adapter Use Case"><img src="/img/udemy_btn_sm.gif" alt="Adapter Use Case"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/fyws-p4WHuk" target="_blank" title="Adapter Use Case"><img src="/img/yt_btn_sm.gif" alt="Adapter Use Case"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Adapter Use Case"><img src="/img/skillshare_btn_sm.gif" alt="Adapter Use Case"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
9+
Python **isinstance()** Function | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25401048/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Python isinstance() Function"><img src="/img/udemy_btn_sm.gif" alt="Python isinstance() Function"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/Y6DzwI8xBA8" target="_blank" title="Python isinstance() Function"><img src="/img/yt_btn_sm.gif" alt="Python isinstance() Function"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Python isinstance() Function"><img src="/img/skillshare_btn_sm.gif" alt="Python isinstance() Function"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
10+
Python **time** Module | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25414958/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Python time Module"><img src="/img/udemy_btn_sm.gif" alt="Python time Module"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/WZTZeGB3o3U" target="_blank" title="Python time Module"><img src="/img/yt_btn_sm.gif" alt="Python time Module"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Python time Module"><img src="/img/skillshare_btn_sm.gif" alt="Python time Module"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
11+
312
## Book
413

514
Cover | Links
@@ -161,11 +170,3 @@ I also use the `time` module to sleep for a second between loops to simulate a 1
161170
```
162171

163172
When executing [/adapter/cube_a.py](/adapter/cube_a.py) you will notice that the process will run for about 10 seconds outputting the gradual progress of the construction of each cube.
164-
165-
## Summary
166-
167-
* Use the Adapter when you want to use an existing class, but its interface does not match what you need.
168-
* The adapter adapts to the interface of its parent class for those situations when it is not viable to modify the parent class to be domain-specific for your use case.
169-
* Adapters will most likely provide an alternative interface over an existing object, class or interface, but it can also provide extra functionality that the object being adapted may not already provide.
170-
* An adapter is similar to a [Decorator](/decorator) except that it changes the interface to the object, whereas the decorator adds responsibility without changing the interface. This also allows the Decorator to be used recursively.
171-
* An adapter is similar to the [Bridge](/bridge) pattern and may look identical after the refactoring has been completed. However, the intent of creating the Adapter is different. The Bridge is a result of refactoring existing interfaces, whereas the Adapter is about adapting over existing interfaces that are not viable to modify due to many existing constraints. E.g., you don't have access to the original code or it may have dependencies that already use it and modifying it would affect those dependencies negatively.

bridge/README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Bridge Design Pattern
22

3+
## Videos
4+
5+
| Section | Video Links |
6+
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
7+
| Bridge Overview | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25451260/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Bridge Overview"><img src="/img/udemy_btn_sm.gif" alt="Bridge Overview"/></a>&nbsp; <a id="ytVideoLink" href="https://youtu.be/aCpZI9nfO-E" target="_blank" title="Bridge Overview"><img src="/img/yt_btn_sm.gif" alt="Bridge Overview"/></a>&nbsp; <a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Bridge Overview"><img src="/img/skillshare_btn_sm.gif" alt="Bridge Overview"/></a>&nbsp; <a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>|
8+
| Bridge Use Case | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25451262/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Bridge Use Case"><img src="/img/udemy_btn_sm.gif" alt="Bridge Use Case"/></a>&nbsp; <a id="ytVideoLink" href="https://youtu.be/E7T09yfROQ4" target="_blank" title="Bridge Use Case"><img src="/img/yt_btn_sm.gif" alt="Bridge Use Case"/></a>&nbsp; <a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Bridge Use Case"><img src="/img/skillshare_btn_sm.gif" alt="Bridge Use Case"/></a>&nbsp; <a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>|
9+
| Python **Tuple** | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25473560/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Python Tuple"><img src="/img/udemy_btn_sm.gif" alt="Python Tuple"/></a>&nbsp; <a id="ytVideoLink" href="https://youtu.be/pwjsBmQOyXU" target="_blank" title="Python Tuple"><img src="/img/yt_btn_sm.gif" alt="Python Tuple"/></a>&nbsp; <a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Python Tuple"><img src="/img/skillshare_btn_sm.gif" alt="Python Tuple"/></a>&nbsp; <a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>|
10+
| Python **\*args** | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25473568/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Python *args"><img src="/img/udemy_btn_sm.gif" alt="Python *args"/></a>&nbsp; <a id="ytVideoLink" href="https://youtu.be/0I-dglm0aNQ" target="_blank" title="Python *args"><img src="/img/yt_btn_sm.gif" alt="Python *args"/></a>&nbsp; <a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Python *args"><img src="/img/skillshare_btn_sm.gif" alt="Python *args"/></a>&nbsp; <a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>|
11+
312
## Book
413

514
Cover | Links
@@ -76,7 +85,7 @@ c
7685

7786
In this example, I draw a square and a circle. Both of these can be categorized as shapes.
7887

79-
The shape is set up as the abstraction interface. The refined abstractions, `Square` and `Circle`, implement the `IShape` interface.
88+
The shape is set up as the abstraction interface. The refined abstractions, `Square` and `Circle` , implement the `IShape` interface.
8089

8190
When the Square and Circle objects are created, they are also assigned their appropriate implementers being `SquareImplementer` and `CircleImplementer` .
8291

@@ -95,18 +104,22 @@ python ./bridge/client.py
95104
******
96105
** **
97106
* *
107+
98108
* *
99109
* *
110+
100111
* *
101112
** **
102113
******
103114
**************
115+
104116
* *
105117
* *
106118
* *
107119
* *
108120
* *
109121
* *
122+
110123
**************
111124
```
112125

@@ -143,7 +156,7 @@ Outputs
143156

144157
A Python **Tuple** is similar to a [List](/builder#python-list). Except that the items in the Tuple are ordered, unchangeable and allow duplicates.
145158

146-
A Tuple can be instantiated using the round brackets `()` or `tuple()`, verses `[]` for a [List](/builder#python-list) and `{}` for a [Set](/observer#python-set) or [Dictionary](/singleton#python-dictionary).
159+
A Tuple can be instantiated using the round brackets `()` or `tuple()` , verses `[]` for a [List](/builder#python-list) and `{}` for a [Set](/observer#python-set) or [Dictionary](/singleton#python-dictionary).
147160

148161
``` python
149162
PS> python
@@ -153,10 +166,3 @@ PS> python
153166
>>> print(len(items))
154167
4
155168
```
156-
157-
## Summary
158-
159-
* Use when you want to separate a solution where the abstraction and implementation may be tightly coupled and you want to break it up into smaller conceptual parts.
160-
* Once you have added the bridge abstraction, you should be able to extend each side of it separately without breaking the other.
161-
* Also, once the bridge abstraction exists, you can more easily create extra concrete implementations for other similar products that may also happen to be split across similar conceptual lines.
162-
* The Bridge pattern is similar to the adapter pattern except in the intent that you developed it. The bridge is an approach to refactor already existing code, whereas the adapter adapts to the existing code through its existing interfaces and methods without changing the internals.

composite/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Composite Design Pattern
22

3+
## Videos
4+
5+
Section | Video Links
6+
-|-
7+
Composite Overview | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/16511234/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Composite Overview"><img src="/img/udemy_btn_sm.gif" alt="Composite Overview"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/Wihw5oIsh2g" target="_blank" title="Composite Overview"><img src="/img/yt_btn_sm.gif" alt="Composite Overview"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Composite Overview"><img src="/img/skillshare_btn_sm.gif" alt="Composite Overview"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
8+
Composite Use Case | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25473576/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Composite Use Case"><img src="/img/udemy_btn_sm.gif" alt="Composite Use Case"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/5MjYcxO_TUk" target="_blank" title="Composite Use Case"><img src="/img/yt_btn_sm.gif" alt="Composite Use Case"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Composite Use Case"><img src="/img/skillshare_btn_sm.gif" alt="Composite Use Case"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
9+
Conditional Expressions | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25473582/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Conditional Expressions"><img src="/img/udemy_btn_sm.gif" alt="Conditional Expressions"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/meX3QlEJI2Q" target="_blank" title="Conditional Expressions"><img src="/img/yt_btn_sm.gif" alt="Conditional Expressions"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Conditional Expressions"><img src="/img/skillshare_btn_sm.gif" alt="Conditional Expressions"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
10+
311
## Book
412

513
Cover | Links
@@ -139,10 +147,3 @@ print(ALERTING)
139147
```
140148

141149
Visit [https://docs.python.org/3/reference/expressions.html#conditional-expressions](https://docs.python.org/3/reference/expressions.html#conditional-expressions) for more examples of conditional expressions.
142-
143-
## Summary
144-
145-
* The Composite design pattern allows you to structure components in a manageable hierarchal order.
146-
* It provides flexibility of structure since you can add/remove and reorder components.
147-
* File explorer on windows is a very good example of the composite design pattern in use.
148-
* Any system where you need to offer at runtime the ability to group, un-group, modify multiple objects at the same time, would benefit from the composite design pattern structure. Programs that allow you to draw shapes and graphics will often also use this structure as well.

decorator/README.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
## Videos
44

5-
Section | Video Link
5+
Section | Video Links
66
-|-
7-
Overview | <a id="ytVideoLink" href="https://youtu.be/XRCIKQD81rQ" target="_blank" title="Overview"><img src="/img/yt_btn_sm.gif" alt="Overview"/></a>
8-
Example Use Case | <a id="ytVideoLink" href="https://youtu.be/8uDGo9DjHUc" target="_blank" title="Use Case"><img src="/img/yt_btn_sm.gif" alt="Use Case"/></a>
9-
\__str\__ Dunder Method | <a id="ytVideoLink" href="https://youtu.be/X84ZnxYGKFs" target="_blank" title="__str__ Dunder Method"><img src="/img/yt_btn_sm.gif" alt="__str__ Dunder Method"/></a>
10-
getattr() Method | <a id="ytVideoLink" href="https://youtu.be/y27BD51JKU4" target="_blank" title="getattr() Method"><img src="/img/yt_btn_sm.gif" alt="getattr() Method"/></a>
7+
Decorator Overview | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/16397502/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Decorator Overview"><img src="/img/udemy_btn_sm.gif" alt="Decorator Overview"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/XRCIKQD81rQ" target="_blank" title="Decorator Overview"><img src="/img/yt_btn_sm.gif" alt="Decorator Overview"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Decorator Overview"><img src="/img/skillshare_btn_sm.gif" alt="Decorator Overview"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
8+
Decorator Use Case | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25378590/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Decorator Use Case"><img src="/img/udemy_btn_sm.gif" alt="Decorator Use Case"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/8uDGo9DjHUc" target="_blank" title="Decorator Use Case"><img src="/img/yt_btn_sm.gif" alt="Decorator Use Case"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Decorator Use Case"><img src="/img/skillshare_btn_sm.gif" alt="Decorator Use Case"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
9+
**\__str\__** Dunder Method| <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25378604/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="__str__ Dunder Method"><img src="/img/udemy_btn_sm.gif" alt="__str__ Dunder Method"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/X84ZnxYGKFs" target="_blank" title="__str__ Dunder Method"><img src="/img/yt_btn_sm.gif" alt="__str__ Dunder Method"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="__str__ Dunder Method"><img src="/img/skillshare_btn_sm.gif" alt="__str__ Dunder Method"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
10+
Python **getattr()** Method | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25378618/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="getattr() Method"><img src="/img/udemy_btn_sm.gif" alt="getattr() Method"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/y27BD51JKU4" target="_blank" title="getattr() Method"><img src="/img/yt_btn_sm.gif" alt="getattr() Method"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="getattr() Method"><img src="/img/skillshare_btn_sm.gif" alt="getattr() Method"/></a>&nbsp;<a id="sbcodeVideoLink" href="#"><input type="image" src="/img/sbcode_btn_sm.gif" onclick="selectVideoId()"></a>
1111

1212
## Book
1313

@@ -148,12 +148,3 @@ In all the classes in the above use case example that implement the `IValue` int
148148
```
149149

150150
The `__str__` dunder was also overridden in the [/prototype/prototype_concept.py](/prototype/prototype_concept.py) concept code.
151-
152-
## Summary
153-
154-
* Use the decorator when you want to add responsibilities to objects dynamically without affecting the inner object.
155-
* You want the option to later remove the decorator from an object in case you no longer need it.
156-
* It is an alternative method to creating multiple combinations of subclasses. I.e., Instead of creating a subclass with all combinations of objects A, B, C in any order, and including/excluding objects, you could create 3 objects that can decorate each other in any order you want. E.g., (D(A(C))) or (B(C)) or (A(B(A(C)))
157-
* The decorator, compared to using static inheritance to extend, is more flexible since you can easily add/remove the decorators at runtime. E.g., use in a recursive function.
158-
* A decorator supports recursive composition. E.g., halve(halve(number))
159-
* A decorator shouldn't modify the internal objects data or references. This allows the original object to stay intact if the decorator is later removed.

0 commit comments

Comments
 (0)