You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,15 +73,19 @@ So, in this book, you will learn about these 23 Design Patterns,
73
73
74
74
## Pattern Types
75
75
76
-
In the list of patterns above, there are Creational, Structural and Behavioral patterns.
76
+
*...Refer to Book or Videos for extra content.*
77
+
78
+
<!-- In the list of patterns above, there are Creational, Structural and Behavioral patterns.
77
79
78
80
* **Creational** : Abstracts the instantiation process so that there is a logical separation between how objects are composed and finally represented.
79
81
* **Structural** : Structural patterns focus more on how classed and objects are composed using the different structural techniques, and to form structures with more or altered flexibility.
80
-
***Behavioral** : Are concerned with the inner algorithms, process flow, the assignment of responsibilities and the intercommunication between objects.
82
+
* **Behavioral** : Are concerned with the inner algorithms, process flow, the assignment of responsibilities and the intercommunication between objects. -->
81
83
82
84
## Class Scope and Object Scope Patterns
83
85
84
-
Each pattern can be further specified whether it relates more specifically classes or instantiated objects.
86
+
*...Refer to Book or Videos for extra content.*
87
+
88
+
<!-- Each pattern can be further specified whether it relates more specifically classes or instantiated objects.
85
89
86
90
Class scope patterns deal more with relationships between classes and their subclasses.
87
91
@@ -93,4 +97,4 @@ Object scope patterns deal more with relationships that can be altered at runtim
Copy file name to clipboardExpand all lines: adapter/README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,11 +48,13 @@ The Adapter is used when you have an existing interface that doesn't directly ma
48
48
49
49
## Source Code
50
50
51
-
In this concept source code, there are two classes, `ClassA` and `ClassB`, with different method signatures. Let's consider that `ClassA` provides the most compatible and preferred interface for the client.
51
+
*...Refer to Book or Videos for extra content.*
52
+
53
+
<!-- In this concept source code, there are two classes, `ClassA` and `ClassB`, with different method signatures. Let's consider that `ClassA` provides the most compatible and preferred interface for the client.
52
54
53
55
I can create objects of both classes in the client and it works. But before using each objects method, I need to do a conditional check to see which type of class it is that I am calling since the method signatures are different.
54
56
55
-
It means that the client is doing extra work. Instead, I can create an Adapter interface for the incompatible `ClassB`, that reduces the need for the extra conditional logic.
57
+
It means that the client is doing extra work. Instead, I can create an Adapter interface for the incompatible `ClassB`, that reduces the need for the extra conditional logic.-->
56
58
57
59
## Output
58
60
@@ -66,14 +68,16 @@ method B
66
68
67
69
## Example Use Case
68
70
69
-
The example client can manufacture a **Cube** using different tools. Each solution is invented by a different company.
71
+
*...Refer to Book or Videos for extra content.*
72
+
73
+
<!-- The example client can manufacture a **Cube** using different tools. Each solution is invented by a different company.
70
74
The client user interface manages the Cube product by indicating the **width**, **height** and **depth**. This is compatible with the company A that produces the Cube tool, but not the company B that produces their own version of the Cube tool that uses a different interface with different parameters.
71
75
72
76
In this example, the client will re-use the interface for company A's Cube and create a compatible Cube from company B.
73
77
74
78
An adapter will be needed so that the same method signature can be used by the client without the need to ask company B to modify their Cube tool for our specific domains use case.
75
79
76
-
My imaginary company needs to use both cube suppliers since there is a large demand for cubes and when one supplier is busy, I can then ask the other supplier.
80
+
My imaginary company needs to use both cube suppliers since there is a large demand for cubes and when one supplier is busy, I can then ask the other supplier.-->
Copy file name to clipboardExpand all lines: bridge/README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,11 +65,13 @@ The implementer part of a Bridge, can have one or more possible implementations
65
65
66
66
## Source Code
67
67
68
-
In the concept demonstration code, imagine that the classes were tightly coupled. The concrete class would print out some text to the console.
68
+
*...Refer to Book or Videos for extra content.*
69
+
70
+
<!-- In the concept demonstration code, imagine that the classes were tightly coupled. The concrete class would print out some text to the console.
69
71
70
72
After abstracting the class along a common ground, it is now more versatile. The implementation and has been separated from the abstraction and now it can print out the same text in two different ways.
71
73
72
-
The befit now is that each refined abstraction and implementer can now be worked on independently without affecting the other implementations.
74
+
The befit now is that each refined abstraction and implementer can now be worked on independently without affecting the other implementations.-->
73
75
74
76
## Output
75
77
@@ -83,15 +85,17 @@ c
83
85
84
86
## Example Use Case
85
87
86
-
In this example, I draw a square and a circle. Both of these can be categorized as shapes.
88
+
*...Refer to Book or Videos for extra content.*
89
+
90
+
<!-- In this example, I draw a square and a circle. Both of these can be categorized as shapes.
87
91
88
92
The shape is set up as the abstraction interface. The refined abstractions, `Square` and `Circle` , implement the `IShape` interface.
89
93
90
94
When the Square and Circle objects are created, they are also assigned their appropriate implementers being `SquareImplementer` and `CircleImplementer` .
91
95
92
96
When each shape's `draw` method is called, the equivalent method within their implementer is called.
93
97
94
-
The Square and Circle are bridged and each implementer and abstraction can be worked on independently.
98
+
The Square and Circle are bridged and each implementer and abstraction can be worked on independently.-->
Copy file name to clipboardExpand all lines: facade/README.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,9 +41,11 @@ B
41
41
42
42
## Example Use Case
43
43
44
-
This is an example of a game engine API. The facade layer is creating one streamlined interface consisting of several methods from several larger API backend systems.
44
+
*...Refer to Book or Videos for extra content.*
45
45
46
-
The client could connect directly to each subsystems API and implement its authentication protocols, specific methods, etc. While it is possible, it would be quite a lot of consideration for each of the development teams, so the facade API unifies the common methods which becomes much less overwhelming for each new the client developer to integrate into.
46
+
<!-- This is an example of a game engine API. The facade layer is creating one streamlined interface consisting of several methods from several larger API backend systems.
47
+
48
+
The client could connect directly to each subsystems API and implement its authentication protocols, specific methods, etc. While it is possible, it would be quite a lot of consideration for each of the development teams, so the facade API unifies the common methods which becomes much less overwhelming for each new the client developer to integrate into. -->
Copy file name to clipboardExpand all lines: flyweight/README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,11 +50,13 @@ When describing flyweights, it is useful to describe it in terms of intrinsic an
50
50
51
51
## Source Code
52
52
53
-
A context is created using the string `abracadabra`.
53
+
*...Refer to Book or Videos for extra content.*
54
+
55
+
<!-- A context is created using the string `abracadabra`.
54
56
55
57
As it is output, it asks the Flyweight factory for the next character. The Flyweight factory will either return an existing Flyweight, or create a new one before returning it.
56
58
57
-
`abracadabra` has many re-used characters, so only 5 flyweights needed to be created.
59
+
`abracadabra` has many re-used characters, so only 5 flyweights needed to be created.-->
58
60
59
61
## Output
60
62
@@ -67,11 +69,13 @@ FlyweightFactory has 5 flyweights
67
69
68
70
## Example Use Case
69
71
70
-
In this example, I create a dynamic table with 3 rows and 3 columns each. The columns are then filled with some kind of text, and also chosen to be left, right or center aligned.
72
+
*...Refer to Book or Videos for extra content.*
73
+
74
+
<!-- In this example, I create a dynamic table with 3 rows and 3 columns each. The columns are then filled with some kind of text, and also chosen to be left, right or center aligned.
71
75
72
76
The letters are the flyweights and only a code indicating the letter is stored. The letters and numbers are shared many times.
73
77
74
-
The columns are the contexts and they pass the extrinsic vales describing the combination of letters, the justification left, right or center, and the width of the table column that is then used for the space padding.
78
+
The columns are the contexts and they pass the extrinsic vales describing the combination of letters, the justification left, right or center, and the width of the table column that is then used for the space padding.-->
Copy file name to clipboardExpand all lines: interpreter/README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,9 @@ Once the AST is created, you can then choose the root node and then run the Inte
57
57
58
58
## Source Code
59
59
60
-
In this example, I interpret the string `5 + 4 - 3 + 7 - 2` and then calculate the result.
60
+
*...Refer to Book or Videos for extra content.*
61
+
62
+
<!-- In this example, I interpret the string `5 + 4 - 3 + 7 - 2` and then calculate the result.
61
63
62
64
The grammar of the string follows a pattern of Number -> Operator -> Number -> etc.
63
65
@@ -70,7 +72,7 @@ I then construct the AST manually, by adding a
70
72
3. Non-Terminal `Add` row containing the previous Non-Terminal row and the `7`
71
73
4. Non-Terminal `Subtract` row containing the previous Non-Terminal row and the `2`
72
74
73
-
The AST root becomes the final row that was added, and then I can run the `interpret()` method on that, which will interpret the full AST recursively because each AST row references the row above it.
75
+
The AST root becomes the final row that was added, and then I can run the `interpret()` method on that, which will interpret the full AST recursively because each AST row references the row above it.-->
The example use case will expand on the concept example by dynamically creating the AST and converting roman numerals to integers as well as calculating the final result.
89
+
*...Refer to Book or Videos for extra content.*
90
+
91
+
<!-- The example use case will expand on the concept example by dynamically creating the AST and converting roman numerals to integers as well as calculating the final result.
88
92
89
-
The Image below, is an AST for the expression `5 + IV - 3 + VII - 2`
93
+
The Image below, is an AST for the expression `5 + IV - 3 + VII - 2` -->
90
94
91
95

Copy file name to clipboardExpand all lines: iterator/README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,13 +36,15 @@ The benefits of using the Iterator pattern are that the client can traverse a co
36
36
37
37
## Source Code
38
38
39
-
In this concept example, I create 4 objects called Aggregate and group them into a collection.
39
+
*...Refer to Book or Videos for extra content.*
40
+
41
+
<!-- In this concept example, I create 4 objects called Aggregate and group them into a collection.
40
42
41
43
They are very minimal objects that implement one method that prints a line.
42
44
43
45
I then create an Iterable and pass in the collection of Aggregates.
44
46
45
-
I can now traverse the aggregates through the Iterable interface.
47
+
I can now traverse the aggregates through the Iterable interface.-->
46
48
47
49
## Output
48
50
@@ -56,13 +58,15 @@ This method has been invoked
56
58
57
59
## Example Use Case
58
60
59
-
One reason for not using the inbuilt Python data structures that implement iterators already, or using the [iter](#python-iter) function directly over an existing collection, is in the case when you want to create an object that can dynamically create iterated objects, you want a custom order of objects or an infinite iterator.
61
+
*...Refer to Book or Videos for extra content.*
62
+
63
+
<!-- One reason for not using the inbuilt Python data structures that implement iterators already, or using the [iter](#python-iter) function directly over an existing collection, is in the case when you want to create an object that can dynamically create iterated objects, you want a custom order of objects or an infinite iterator.
60
64
61
65
The iterator in this brief example will return the next number in the iterator multiplied by 2 modulus 11. It dynamically creates the returned object (number) at runtime.
62
66
63
67
It has no `has_next()` method since the result is modulated by 11, that will loop the results no matter how large the iterator index is. It will also appear to alternate between a series of even numbers and odd numbers.
64
68
65
-
Also, just to demonstrate that implementing abstract classes and interfaces is not always necessary, this example uses no abstract base classes or interfaces.
69
+
Also, just to demonstrate that implementing abstract classes and interfaces is not always necessary, this example uses no abstract base classes or interfaces.-->
Copy file name to clipboardExpand all lines: mediator/README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,11 +34,13 @@ While the Facade is a structural pattern, and the Mediator also implies structur
34
34
35
35
## Source Code
36
36
37
-
In the example concept, there are two colleague classes that use each other's methods. Instead of the Colleagues calling each other's methods directly, they implement the Mediator interface and call each other via the Mediator. Each colleague is designed for a different purpose, but they utilize some related functionality from each other.
37
+
*...Refer to Book or Videos for extra content.*
38
+
39
+
<!-- In the example concept, there are two colleague classes that use each other's methods. Instead of the Colleagues calling each other's methods directly, they implement the Mediator interface and call each other via the Mediator. Each colleague is designed for a different purpose, but they utilize some related functionality from each other.
38
40
39
41
The system, in this case, would work without the Mediator, but adding the Mediator would allow extending functionality to a potential third colleague that provides a different service, such as AI analysis or monitoring, without needing to add specific support or knowledge into the two original colleagues.
40
42
41
-
In this first example the Mediator is structurally acting as a multi directional relay between the two colleagues.
43
+
In this first example the Mediator is structurally acting as a multi directional relay between the two colleagues.-->
42
44
43
45
## Output
44
46
@@ -50,13 +52,15 @@ COLLEAGUE2 <--> Here is the Colleague1 specific data you asked for
50
52
51
53
## Example Use Case
52
54
53
-
In this example use case, we will implement some behavior into the mediation process.
55
+
*...Refer to Book or Videos for extra content.*
56
+
57
+
<!-- In this example use case, we will implement some behavior into the mediation process.
54
58
55
59
Before the mediation logic is added, consider that the below example is a series of components all subscribed to a central location being the subject. They all implement the [Observer](/observer) pattern.
56
60
57
61
Each component is updated independently by external forces, but when it has new information, it notifies the subject which in turn then notifies the other subscribed components.
58
62
59
-
During the synchronization of all the subscribed components, without the extra mediation, the component that provided the new information will receive back the same message that it just notified the subject of. In order to manage the unnecessary duplicate message, the notifications will be mediated to exclude to component where the original message originated from.
63
+
During the synchronization of all the subscribed components, without the extra mediation, the component that provided the new information will receive back the same message that it just notified the subject of. In order to manage the unnecessary duplicate message, the notifications will be mediated to exclude to component where the original message originated from.-->
0 commit comments