Skip to content

Commit 83d007e

Browse files
committed
updates
1 parent 152aa64 commit 83d007e

File tree

7 files changed

+51
-24
lines changed

7 files changed

+51
-24
lines changed

abstract_factory/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ python ./abstract_factory/abstract_factory_concept.py
4646

4747
## Abstract Factory Example Use Case
4848

49-
An example use case may be that you have a furniture shop front. You sell many different kinds of furniture. You sell chairs and tables. And they are manufactured at different factories using different unrelated processes that are not important for your concern. You only need the factory to deliver.
49+
*...Refer to Book or Videos for extra content.*
5050

51-
You can create an extra module called `FurnitureFactory`, to handle the chair and table factories, thus removing the implementation details from the client.
51+
<!-- An example use case may be that you have a furniture shop front. You sell many different kinds of furniture. You sell chairs and tables. And they are manufactured at different factories using different unrelated processes that are not important for your concern. You only need the factory to deliver.
52+
53+
You can create an extra module called `FurnitureFactory`, to handle the chair and table factories, thus removing the implementation details from the client. -->
5254

5355
## Abstract Factory Example UML Diagram
5456

builder/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ The Builder and Factory patterns are very similar in the fact they both instanti
3838

3939
## Source Code
4040

41-
1. Client creates the **Director**.
41+
*...Refer to Book or Videos for extra content.*
42+
43+
<!-- 1. Client creates the **Director**.
4244
2. The Client calls the Directors `construct()` method that manages each step of the build process.
43-
3. The Director returns the product to the client or alternatively could also provide a method for the client to retrieve it later.
45+
3. The Director returns the product to the client or alternatively could also provide a method for the client to retrieve it later. -->
4446

4547
## Output
4648

@@ -51,13 +53,15 @@ python ./builder/builder_concept.py
5153

5254
## Example Use Case
5355

54-
Using the Builder Pattern in the context of a House Builder.
56+
*...Refer to Book or Videos for extra content.*
57+
58+
<!-- Using the Builder Pattern in the context of a House Builder.
5559
5660
There are multiple directors that can create their own complex objects.
5761
5862
Note that in the `IglooDirector` class, not all of the methods of the `HouseBuilder` were called.
5963
60-
The builder can construct complex objects in any order and include/exclude whichever parts it likes.
64+
The builder can construct complex objects in any order and include/exclude whichever parts it likes. -->
6165

6266
## Example UML Diagram
6367

chain_of_responsibility/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ The chain that the object will pass through is normally dynamic at runtime, alth
3939

4040
## Source Code
4141

42-
In this concept code, a chain is created with a default first successor. A number is passed to a successor, which then does a random test, and depending on the result will modify the number and then pass it onto the next successor. The process is randomized and will end at some point when there are no more successors designated.
42+
*...Refer to Book or Videos for extra content.*
43+
44+
<!-- In this concept code, a chain is created with a default first successor. A number is passed to a successor, which then does a random test, and depending on the result will modify the number and then pass it onto the next successor. The process is randomized and will end at some point when there are no more successors designated. -->
4345

4446
## Output
4547

@@ -57,11 +59,14 @@ Finished result = -1.5
5759

5860
## Example Use Case
5961

62+
*...Refer to Book or Videos for extra content.*
63+
64+
<!--
6065
In the ATM example below, the chain is hard coded in the client first to dispense amounts of £50s, then £20s and then £10s in order.
6166
6267
This default chain order helps to ensure that the minimum number of notes will be dispensed. Otherwise, it might dispense 5 x £10 when it would have been better to dispense 1 x £50.
6368
64-
Each successor may be re-called recursively for each denomination depending on the value that was requested for withdrawal.
69+
Each successor may be re-called recursively for each denomination depending on the value that was requested for withdrawal. -->
6570

6671
## Example UML Diagram
6772

command/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ Uses:
5151

5252
## Source Code
5353

54-
The Client instantiates a Receiver that accepts certain commands.
54+
*...Refer to Book or Videos for extra content.*
55+
56+
<!-- The Client instantiates a Receiver that accepts certain commands.
5557
5658
The Client then creates two Command objects that will call one of the specific commands on the Receiver.
5759
5860
The Client then creates an Invoker, E.g., a user interface with buttons, and registers both Commands into the Invokers dictionary of commands.
5961
6062
The Client doesn't call the receivers commands directly, but the via the Invoker, which then calls the registered Command objects `execute()` method.
6163
62-
This abstraction between the invoker, command and receiver, allows the Invoker to add extra functionality such as history, replay, UNDO/REDO, logging, alerting and any other useful things that may be required.
64+
This abstraction between the invoker, command and receiver, allows the Invoker to add extra functionality such as history, replay, UNDO/REDO, logging, alerting and any other useful things that may be required. -->
6365

6466
## Output
6567

@@ -73,13 +75,15 @@ Executing Command 2
7375

7476
## Example Use Case
7577

76-
This will be a smart light switch.
78+
*...Refer to Book or Videos for extra content.*
79+
80+
<!-- This will be a smart light switch.
7781
7882
This light switch will keep a history of each time one of its commands was called.
7983
8084
And it can replay its commands.
8185
82-
A smart light switch could be extended in the future to be called remotely or automated depending on sensors.
86+
A smart light switch could be extended in the future to be called remotely or automated depending on sensors. -->
8387

8488
## Example UML Diagram
8589

factory/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ The Factory pattern is really about adding that extra abstraction between the ob
4848

4949
## Source Code
5050

51-
In this concept example, the client wants an object named `b`
51+
*...Refer to Book or Videos for extra content.*
52+
53+
<!-- In this concept example, the client wants an object named `b`
5254
5355
Rather than creating `b` directly in the client, it asks the creator (factory) for the object instead.
5456
55-
The factory finds the relevant class using some kind of logic from the attributes of the request. It then asks the subclass to instantiate the new object which it then returns as a reference back to the client asking for it.
57+
The factory finds the relevant class using some kind of logic from the attributes of the request. It then asks the subclass to instantiate the new object which it then returns as a reference back to the client asking for it. -->
5658

5759
## Output
5860

@@ -63,11 +65,13 @@ ConcreteProductB
6365

6466
## Example Use Case
6567

66-
An example use case is a user interface where the user can select from a menu of items, such as chairs.
68+
*...Refer to Book or Videos for extra content.*
69+
70+
<!-- An example use case is a user interface where the user can select from a menu of items, such as chairs.
6771
6872
The user has been given a choice using some kind of navigation interface, and it is unknown what choice, or how many the user will make until the application is actually running and the user starts using it.
6973
70-
So, when the user selected the chair, the factory then takes some property involved with that selection, such as an ID, Type or other attribute and then decides which relevant subclass to instantiate in order to return the appropriate object.
74+
So, when the user selected the chair, the factory then takes some property involved with that selection, such as an ID, Type or other attribute and then decides which relevant subclass to instantiate in order to return the appropriate object. -->
7175

7276
## Factory Example UML Diagram
7377

observer/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,17 @@ If updates on the observer end are allowed to suffer from some delay, then a pul
5959

6060
## Source Code
6161

62-
A Subject (Observable) is created.
62+
*...Refer to Book or Videos for extra content.*
63+
64+
<!-- A Subject (Observable) is created.
6365
6466
Two Observers are created. They could be across a network, but for demonstration purposes are within the same client.
6567
6668
The Subject notifies the Observers.
6769
6870
One of the Observers unsubscribes,
6971
70-
The Subject notifies the remaining Observer again.
72+
The Subject notifies the remaining Observer again. -->
7173

7274
## Output
7375

@@ -80,7 +82,9 @@ Observer id:2084220160272 received ('Second Notification', {'A': 1, 'B': 2, 'C':
8082

8183
## Example Use Case
8284

83-
This example mimics the **MVC** approach described earlier.
85+
*...Refer to Book or Videos for extra content.*
86+
87+
<!-- This example mimics the **MVC** approach described earlier.
8488
8589
There is an external process called a `DataController`, and a client process that holds a `DataModel` and multiple `DataViews` which are a Pie graph, Bar graph and Table view.
8690
@@ -94,7 +98,7 @@ The hypothetical external `DataController` then updates the external data, and t
9498
9599
Note that in reality this example would be much more complex if multiple servers are involved. I am keeping it brief to demonstrate one possible use case of the observer pattern.
96100
97-
Also note that in the `DataController`, the references to the observers are contained in a [Set](#python-set), while in the `DataModel` I have used a [Dictionary](/singleton#python-dictionary) instead, so that you can see an alternate approach.
101+
Also note that in the `DataController`, the references to the observers are contained in a [Set](#python-set), while in the `DataModel` I have used a [Dictionary](/singleton#python-dictionary) instead, so that you can see an alternate approach. -->
98102

99103
## Example UML Diagram
100104

visitor/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ Similar to the template pattern it could be used to output different versions of
4242

4343
## Source Code
4444

45-
In the concept code below, a hierarchy of any object is created. It is similar to a simplified composite. The objects of `Element` can also contain a hierarchy of sub elements.
45+
*...Refer to Book or Videos for extra content.*
46+
47+
<!-- In the concept code below, a hierarchy of any object is created. It is similar to a simplified composite. The objects of `Element` can also contain a hierarchy of sub elements.
4648
4749
The `Element` class could also consist of many variations, but this example uses only one.
4850
4951
Rather than writing specific code inside all these elements every time I wanted to handle a new custom operation, I can implement the `IVisitable` interface and create the `accept()` method which allows the Visitor to pass through it and access the Elements internal attributes.
5052
51-
Two different Visitor classes are created, `PrintElementNamesVisitor` and `CalculateElementTotalsVisitor` . They are instantiated and passed through the existing Object hierarchy using the same `IVisitable` interface.
53+
Two different Visitor classes are created, `PrintElementNamesVisitor` and `CalculateElementTotalsVisitor` . They are instantiated and passed through the existing Object hierarchy using the same `IVisitable` interface. -->
5254

5355
## Output
5456

@@ -63,13 +65,15 @@ A
6365

6466
## Visitor Example Use Case
6567

66-
In the example, the client creates a car with parts.
68+
*...Refer to Book or Videos for extra content.*
69+
70+
<!-- In the example, the client creates a car with parts.
6771
6872
The car and parts inherit an abstract car parts class with predefined property getters and setters.
6973
7074
Instead of creating methods in the car parts classes and abstract class that run bespoke methods, the car parts can all implement the `IVisitor` interface.
7175
72-
This allows for the later creation of Visitor objects to run specific tasks on the existing hierarchy of objects.
76+
This allows for the later creation of Visitor objects to run specific tasks on the existing hierarchy of objects. -->
7377

7478
## Visitor Example UML Diagram
7579

0 commit comments

Comments
 (0)