Skip to content

Commit f88e02d

Browse files
committed
updates
1 parent 83d007e commit f88e02d

File tree

17 files changed

+115
-57
lines changed

17 files changed

+115
-57
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,19 @@ So, in this book, you will learn about these 23 Design Patterns,
7373

7474
## Pattern Types
7575

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.
7779
7880
* **Creational** : Abstracts the instantiation process so that there is a logical separation between how objects are composed and finally represented.
7981
* **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. -->
8183

8284
## Class Scope and Object Scope Patterns
8385

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.
8589
8690
Class scope patterns deal more with relationships between classes and their subclasses.
8791
@@ -93,4 +97,4 @@ Object scope patterns deal more with relationships that can be altered at runtim
9397
| Builder, Prototype, Singleton | Defers object creation to objects | Object | Creational |
9498
| Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy | Describes a way to assemble objects | Object | Structural |
9599
| Interpreter, Template | Describes algorithms and flow control | Class | Behavioral |
96-
| Chain of Responsibility, Command, Iterator, Mediator, Memento, Observer, State, Strategy, Visitor | Describes how groups of objects co-operate | Object | Behavioral |
100+
| Chain of Responsibility, Command, Iterator, Mediator, Memento, Observer, State, Strategy, Visitor | Describes how groups of objects co-operate | Object | Behavioral | -->

adapter/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ The Adapter is used when you have an existing interface that doesn't directly ma
4848

4949
## Source Code
5050

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.
5254
5355
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.
5456
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. -->
5658

5759
## Output
5860

@@ -66,14 +68,16 @@ method B
6668

6769
## Example Use Case
6870

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.
7074
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.
7175
7276
In this example, the client will re-use the interface for company A's Cube and create a compatible Cube from company B.
7377
7478
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.
7579
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. -->
7781

7882
## Example UML Diagram
7983

bridge/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ The implementer part of a Bridge, can have one or more possible implementations
6565

6666
## Source Code
6767

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.
6971
7072
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.
7173
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. -->
7375

7476
## Output
7577

@@ -83,15 +85,17 @@ c
8385

8486
## Example Use Case
8587

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.
8791
8892
The shape is set up as the abstraction interface. The refined abstractions, `Square` and `Circle` , implement the `IShape` interface.
8993
9094
When the Square and Circle objects are created, they are also assigned their appropriate implementers being `SquareImplementer` and `CircleImplementer` .
9195
9296
When each shape's `draw` method is called, the equivalent method within their implementer is called.
9397
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. -->
9599

96100
## Example UML Diagram
97101

composite/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ Examples of using the Composite Design Pattern can be seen in a file
4040

4141
## Source Code
4242

43-
In this concept code, two leaves are created, `LEAF_A` and `LEAF_B`, and two composites are created, `COMPOSITE_1` and `COMPOSITE_2` .
43+
*...Refer to Book or Videos for extra content.*
44+
45+
<!-- In this concept code, two leaves are created, `LEAF_A` and `LEAF_B`, and two composites are created, `COMPOSITE_1` and `COMPOSITE_2` .
4446
4547
`LEAF_A` is attached to `COMPOSITE_1` .
4648
4749
Then I change my mind and attach `LEAF_A` to `COMPOSITE_2` .
4850
4951
I then attach `COMPOSITE_1` to `COMPOSITE_2` .
5052
51-
`LEAF_B` is not attached to composites.
53+
`LEAF_B` is not attached to composites. -->
5254

5355
## Output
5456

@@ -68,13 +70,15 @@ COMPOSITE_2 id:2050574298128
6870

6971
## Composite Example Use Case
7072

71-
Demonstration of a simple in memory hierarchal file system.
73+
*...Refer to Book or Videos for extra content.*
74+
75+
<!-- Demonstration of a simple in memory hierarchal file system.
7276
7377
A root object is created that is a composite.
7478
7579
Several files (leaves) are created and added to the root folder.
7680
77-
More folders (composites) are created, and more files are added, and then the hierarchy is reordered.
81+
More folders (composites) are created, and more files are added, and then the hierarchy is reordered. -->
7882

7983
## Composite Example UML Diagram
8084

decorator/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ Decorator Method(Component Method)
4949

5050
## Example Use Case
5151

52-
Let's create a custom class called `Value` that will hold a number.
52+
*...Refer to Book or Videos for extra content.*
53+
54+
<!-- Let's create a custom class called `Value` that will hold a number.
5355
5456
Then add decorators that allow addition (`Add`) and subtraction (`Sub`) to a number (`Value`).
5557
5658
The `Add` and `Sub` decorators can accept integers directly, a custom `Value` object or other `Add` and `Sub` decorators.
5759
58-
`Add`, `Sub` and `Value` all implement the `IValue` interface and can be used recursively.
60+
`Add`, `Sub` and `Value` all implement the `IValue` interface and can be used recursively. -->
5961

6062
## Example UML Diagram
6163

facade/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ B
4141

4242
## Example Use Case
4343

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.*
4545

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. -->
4749

4850
## Example UML Diagram
4951

flyweight/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ When describing flyweights, it is useful to describe it in terms of intrinsic an
5050

5151
## Source Code
5252

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`.
5456
5557
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.
5658
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. -->
5860

5961
## Output
6062

@@ -67,11 +69,13 @@ FlyweightFactory has 5 flyweights
6769

6870
## Example Use Case
6971

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.
7175
7276
The letters are the flyweights and only a code indicating the letter is stored. The letters and numbers are shared many times.
7377
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. -->
7579

7680
## Example UML Diagram
7781

interpreter/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ Once the AST is created, you can then choose the root node and then run the Inte
5757

5858
## Source Code
5959

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.
6163
6264
The grammar of the string follows a pattern of Number -> Operator -> Number -> etc.
6365
@@ -70,7 +72,7 @@ I then construct the AST manually, by adding a
7072
3. Non-Terminal `Add` row containing the previous Non-Terminal row and the `7`
7173
4. Non-Terminal `Subtract` row containing the previous Non-Terminal row and the `2`
7274
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. -->
7476

7577
## Output
7678

@@ -84,9 +86,11 @@ python ./interpreter/interpreter_concept.py
8486
8587
## Example Use Case
8688
87-
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.
8892
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` -->
9094
9195
![Abstract Syntax Tree Example](/img/interpreter_ast_roman_numeral.svg)
9296

iterator/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ The benefits of using the Iterator pattern are that the client can traverse a co
3636

3737
## Source Code
3838

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.
4042
4143
They are very minimal objects that implement one method that prints a line.
4244
4345
I then create an Iterable and pass in the collection of Aggregates.
4446
45-
I can now traverse the aggregates through the Iterable interface.
47+
I can now traverse the aggregates through the Iterable interface. -->
4648

4749
## Output
4850

@@ -56,13 +58,15 @@ This method has been invoked
5658

5759
## Example Use Case
5860

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.
6064
6165
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.
6266
6367
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.
6468
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. -->
6670

6771
## Example UML Diagram
6872

mediator/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ While the Facade is a structural pattern, and the Mediator also implies structur
3434

3535
## Source Code
3636

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.
3840
3941
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.
4042
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. -->
4244

4345
## Output
4446

@@ -50,13 +52,15 @@ COLLEAGUE2 <--> Here is the Colleague1 specific data you asked for
5052

5153
## Example Use Case
5254

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.
5458
5559
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.
5660
5761
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.
5862
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. -->
6064

6165
## Example UML Diagram
6266

0 commit comments

Comments
 (0)