Skip to content

Commit 821d5ef

Browse files
committed
updates
1 parent e1227de commit 821d5ef

36 files changed

+62
-62
lines changed

abstract_factory/big_chair.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
class BigChair(IChair): # pylint: disable=too-few-public-methods
6-
"The Big Chair Concrete Class which implements the IChair interface"
6+
"The Big Chair Concrete Class that implements the IChair interface"
77

88
def __init__(self):
99
self._height = 80

abstract_factory/factory_a.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def create_object():
1313

1414

1515
class ConcreteProductA(IProduct):
16-
"A Concrete Class which implements the IProduct interface"
16+
"A Concrete Class that implements the IProduct interface"
1717

1818
def __init__(self):
1919
self.name = "ConcreteProductA"
@@ -23,7 +23,7 @@ def create_object(self):
2323

2424

2525
class ConcreteProductB(IProduct):
26-
"A Concrete Class which implements the IProduct interface"
26+
"A Concrete Class that implements the IProduct interface"
2727

2828
def __init__(self):
2929
self.name = "ConcreteProductB"
@@ -33,7 +33,7 @@ def create_object(self):
3333

3434

3535
class ConcreteProductC(IProduct):
36-
"A Concrete Class which implements the IProduct interface"
36+
"A Concrete Class that implements the IProduct interface"
3737

3838
def __init__(self):
3939
self.name = "ConcreteProductC"

abstract_factory/factory_b.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def create_object():
1313

1414

1515
class ConcreteProductA(IProduct):
16-
"A Concrete Class which implements the IProduct interface"
16+
"A Concrete Class that implements the IProduct interface"
1717

1818
def __init__(self):
1919
self.name = "ConcreteProductA"
@@ -23,7 +23,7 @@ def create_object(self):
2323

2424

2525
class ConcreteProductB(IProduct):
26-
"A Concrete Class which implements the IProduct interface"
26+
"A Concrete Class that implements the IProduct interface"
2727

2828
def __init__(self):
2929
self.name = "ConcreteProductB"
@@ -33,7 +33,7 @@ def create_object(self):
3333

3434

3535
class ConcreteProductC(IProduct):
36-
"A Concrete Class which implements the IProduct interface"
36+
"A Concrete Class that implements the IProduct interface"
3737

3838
def __init__(self):
3939
self.name = "ConcreteProductC"

adapter/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ In this concept source code, there are two classes, `ClassA` and `ClassB`, with
3737

3838
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.
3939

40-
It means that the client is doing extra work. Instead, I can create an Adapter interface for the incompatible `ClassB`, which reduces the need for the extra conditional logic.
40+
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.
4141

4242
## Output
4343

@@ -136,7 +136,7 @@ You can use it in logical statements as I do in [/adapter/adapter_concept.py](/a
136136

137137
The time module provides time related functions, most notably in my case, the current epoch (ticks) since `January 1, 1970, 00:00:00 (UTC)` .
138138

139-
The `time` module provides many options which are outlined in more detail at [https://docs.python.org/3/library/time.html](https://docs.python.org/3/library/time.html)
139+
The `time` module provides many options that are outlined in more detail at [https://docs.python.org/3/library/time.html](https://docs.python.org/3/library/time.html)
140140

141141
In [/adapter/cube_a.py](/adapter/cube_a.py), I check the `time.time()` at various intervals to compare how long a task took.
142142

bridge/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The **Bridge pattern** is similar to the [Adapter](/adapter) pattern except in t
66

77
The Bridge is an approach to refactor already existing code, whereas the Adapter creates an interface on top of existing code through existing available means without refactoring any existing code or interfaces.
88

9-
The motivation for converting your code to the Bridge pattern is that it may be tightly coupled. There is logic and abstraction close together which is limiting your choices in how you can extend your solution in the way that you need.
9+
The motivation for converting your code to the Bridge pattern is that it may be tightly coupled. There is logic and abstraction close together that is limiting your choices in how you can extend your solution in the way that you need.
1010

1111
E.g., you may have one Car class, that produces a very nice car. But you would like the option of varying the design a little, or outsourcing responsibility of creating the different components.
1212

@@ -152,5 +152,5 @@ PS> python
152152

153153
* 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.
154154
* Once you have added the bridge abstraction, you should be able to extend each side of it separately without breaking the other.
155-
* Also, once the bridge abstraction exists, you can more easily create extra concrete implementations for other similar products which may also happen to be split across similar conceptual lines.
155+
* 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.
156156
* 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.

builder/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Builder Pattern tries to solve,
99
* How can a class create different representations of a complex object?
1010
* How can a class that includes creating a complex object be simplified?
1111

12-
The Builder and Factory patterns are very similar in the fact they both instantiate new objects at runtime. The difference is when the process of creating the object is more complex, so rather than the Factory returning a new instance of `ObjectA`, it calls the builders director constructor method `ObjectA.construct()` which goes through a more complex construction process involving several steps. Both return an Object/Product.
12+
The Builder and Factory patterns are very similar in the fact they both instantiate new objects at runtime. The difference is when the process of creating the object is more complex, so rather than the Factory returning a new instance of `ObjectA`, it calls the builders director constructor method `ObjectA.construct()` that goes through a more complex construction process involving several steps. Both return an Object/Product.
1313

1414
## Terminology
1515

@@ -25,7 +25,7 @@ The Builder and Factory patterns are very similar in the fact they both instanti
2525
## Source Code
2626

2727
1. Client creates the **Director**.
28-
2. The Client calls the Directors `construct()` method which manages each step of the build process.
28+
2. The Client calls the Directors `construct()` method that manages each step of the build process.
2929
3. The Director returns the product to the client or alternatively could also provide a method for the client to retrieve it later.
3030

3131
## Output

chain_of_responsibility/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ See PEP-3111 : [https://www.python.org/dev/peps/pep-3111/](https://www.python.or
111111
## Summary
112112

113113
* The object will propagate through the chain until fully processed.
114-
* The object does not know which successor or how many will process it.
114+
* The object does not know that successor or how many will process it.
115115
* The next successor in the chain is chosen dynamically at runtime depending on logic from the current successor.
116-
* Successors implement a common interface which makes them work independently of each other, so that they can be used recursively or possibly in a different order.
116+
* Successors implement a common interface that makes them work independently of each other, so that they can be used recursively or possibly in a different order.
117117
* A user wizard, or dynamic questionnaire are other common use cases for the chain of responsibility pattern.
118118
* The chain of responsibility and [Composite](/composite) patterns are often used together because of their similar approach to hierarchy and possible re-ordering. The Composites parent/child relationship is set in an object's property by a process outside of the class and can be changed at runtime. While with the Chain of Responsibility, each successor runs a dynamic algorithm internally, to decide which successor is next in line.
119119
* The chain can be fully dynamically created, or it can be set as a default with the possibility of changing at runtime.

coding-conventions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The code styling in this repository is formatted using mostly PEP8 styling recom
4646
* **UPPER_CASE** : Constants will be defined using UPPER_CASE naming style.
4747
* **PascalCase** : Class names will use PascalCase naming style
4848
* **snake_case** : For variables names, method names and method arguments.
49-
* **Docstrings** : Classes and methods contain extra documentation which is descriptive text enclosed in " or """ for multiline strings.
49+
* **Docstrings** : Classes and methods contain extra documentation that is descriptive text enclosed in " or """ for multiline strings.
5050
* **_leading_underscore** : Use a leading underscore to indicate variables that should be considered as private class variables.
5151

5252
See PEP-0008 : [https://www.python.org/dev/peps/pep-0008/](https://www.python.org/dev/peps/pep-0008/)

command/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The **Command** pattern is a behavioral design pattern, in which an abstraction exists between an object that invokes a command, and the object that performs it.
66

7-
E.g., a button will call the **Invoker**, which will call a pre-registered **Command**, which the **Receiver** will perform.
7+
E.g., a button will call the **Invoker**, that will call a pre-registered **Command**, that the **Receiver** will perform.
88

99
A Concrete Class will delegate a request to a command object, instead of implementing the request directly.
1010

@@ -28,18 +28,18 @@ Uses:
2828

2929
* **Receiver**: The object that will receive and execute the command.
3030
* **Invoker**: The object that sends the command to the receiver. E.g., A button.
31-
* **Command Object**: Itself, an object, which implements an execute, or action method, and contains all required information to execute it.
32-
* **Client**: The application or component which is aware of the Receiver, Invoker and Commands.
31+
* **Command Object**: Itself, an object, that implements an execute, or action method, and contains all required information to execute it.
32+
* **Client**: The application or component that is aware of the Receiver, Invoker and Commands.
3333

3434
## Command Pattern UML Diagram
3535

3636
![The Command Pattern UML Diagram](/img/command_concept.svg)
3737

3838
## Source Code
3939

40-
The Client instantiates a Receiver which accepts certain commands that do things.
40+
The Client instantiates a Receiver that accepts certain commands.
4141

42-
The Client then creates two Command objects which will call one of the specific commands on the Receiver.
42+
The Client then creates two Command objects that will call one of the specific commands on the Receiver.
4343

4444
The Client then creates an Invoker, E.g., a user interface with buttons, and registers both Commands into the Invokers dictionary of commands.
4545

command/command_concept.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44

55
class ICommand(metaclass=ABCMeta): # pylint: disable=too-few-public-methods
6-
"The command interface, which all commands will implement"
6+
"The command interface, that all commands will implement"
77
@staticmethod
88
@abstractmethod
99
def execute():
10-
"The required execute method which all command objects will use"
10+
"The required execute method that all command objects will use"
1111

1212

1313
class Invoker:
@@ -43,7 +43,7 @@ def run_command_2():
4343

4444

4545
class Command1(ICommand): # pylint: disable=too-few-public-methods
46-
"""A Command object, which implements the ICommand interface and
46+
"""A Command object, that implements the ICommand interface and
4747
runs the command on the designated receiver"""
4848

4949
def __init__(self, receiver):
@@ -54,7 +54,7 @@ def execute(self):
5454

5555

5656
class Command2(ICommand): # pylint: disable=too-few-public-methods
57-
"""A Command object, which implements the ICommand interface and
57+
"""A Command object, that implements the ICommand interface and
5858
runs the command on the designated receiver"""
5959

6060
def __init__(self, receiver):

command/interface_switch.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
"The switch interface, which all commands will implement"
1+
"The switch interface, that all commands will implement"
22
from abc import ABCMeta, abstractmethod
33

44

55
class ISwitch(metaclass=ABCMeta): # pylint: disable=too-few-public-methods
6-
"The switch interface, which all commands will implement"
6+
"The switch interface, that all commands will implement"
77

88
@staticmethod
99
@abstractmethod
1010
def execute():
11-
"The required execute method which all command objects will use"
11+
"The required execute method that all command objects will use"

command/switch_off_command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
A Command object, which implements the ISwitch interface and runs the
2+
A Command object, that implements the ISwitch interface and runs the
33
command on the designated receiver
44
"""
55
from interface_switch import ISwitch

command/switch_on_command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
A Command object, which implements the ISwitch interface and runs the
2+
A Command object, that implements the ISwitch interface and runs the
33
command on the designated receiver
44
"""
55
from interface_switch import ISwitch

composite/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ COMPOSITE_2 id:2050574298128
5656

5757
Demonstration of a simple in memory hierarchal file system.
5858

59-
A root object is created which is a composite.
59+
A root object is created that is a composite.
6060

6161
Several files (leaves) are created and added to the root folder.
6262

composite/folder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"A Folder, which acts as a composite."
1+
"A Folder, that acts as a composite."
22
from interface_component import IComponent
33

44

decorator/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Decorator Method(Component Method)
3434

3535
## Example Use Case
3636

37-
Let's create a custom class called `Value` which will hold a number.
37+
Let's create a custom class called `Value` that will hold a number.
3838

3939
Then add decorators that allow addition (`Add`) and subtraction (`Sub`) to a number (`Value`).
4040

decorator/add.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Add(IValue):
88

99
def __init__(self, val1, val2):
1010
# val1 and val2 can be int or the custom Value
11-
# object which contains the `value` attribute
11+
# object that contains the `value` attribute
1212
val1 = getattr(val1, 'value', val1)
1313
val2 = getattr(val2, 'value', val2)
1414
self.value = val1 + val2

decorator/sub.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Sub(IValue):
88

99
def __init__(self, val1, val2):
1010
# val1 and val2 can be int or the custom Value
11-
# object which contains the `value` attribute
11+
# object that contains the `value` attribute
1212
val1 = getattr(val1, 'value', val1)
1313
val2 = getattr(val2, 'value', val2)
1414
self.value = val1 - val2

facade/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,5 @@ Found 2 errors in 2 files (checked 1 source file)
165165
* You want to layer your subsystems into an abstraction that is easier to understand.
166166
* [Abstract Factory](/abstract_factory) and Facade can be considered very similar. An Abstract Factory is about creating in interface over several creational classes of similar objects, whereas the Facade is more like an API layer over many creational, structural and/or behavioral patterns.
167167
* The [Mediator](/mediator) is similar to the Facade in the way that it abstracts existing classes. The Facade is not intended to modify, load balance or apply any extra logic. A subsystem does not need to consider that existence of the facade, it would still work without it.
168-
* A Facade is a minimal interface which could also be implemented as a [Singleton](/singleton).
168+
* A Facade is a minimal interface that could also be implemented as a [Singleton](/singleton).
169169
* A Facade is an optional layer that does not alter the subsystem. The subsystem does not need to know about the Facade, and could even be used by many other facades created for different audiences.

factory/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ABCMeta refers to **A**bstract **B**ase **C**lasses.
7777

7878
The benefits of using ABCMeta classes to create abstract classes is that your IDE and Pylint will indicate to you at development time whether your inheriting classes conform to the class definition that you've asked them to.
7979

80-
Abstract classes are not instantiated directly in your scripts, but instead inherited by subclasses that will provide the implementation code for the abstract methods. E.g., you don't create `IChair`, but you create `SmallChair` which implemented the methods described in the `IChair` interface.
80+
Abstract classes are not instantiated directly in your scripts, but instead inherited by subclasses that will provide the implementation code for the abstract methods. E.g., you don't create `IChair`, but you create `SmallChair` that implemented the methods described in the `IChair` interface.
8181

8282
An abstract method is a method that is declared, but contains no implementation. The implementation happens at the class that inherits the abstract class.
8383

factory/factory_concept.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def create_object():
1313

1414

1515
class ConcreteProductA(IProduct):
16-
"A Concrete Class which implements the IProduct interface"
16+
"A Concrete Class that implements the IProduct interface"
1717

1818
def __init__(self):
1919
self.name = "ConcreteProductA"
@@ -23,7 +23,7 @@ def create_object(self):
2323

2424

2525
class ConcreteProductB(IProduct):
26-
"A Concrete Class which implements the IProduct interface"
26+
"A Concrete Class that implements the IProduct interface"
2727

2828
def __init__(self):
2929
self.name = "ConcreteProductB"
@@ -33,7 +33,7 @@ def create_object(self):
3333

3434

3535
class ConcreteProductC(IProduct):
36-
"A Concrete Class which implements the IProduct interface"
36+
"A Concrete Class that implements the IProduct interface"
3737

3838
def __init__(self):
3939
self.name = "ConcreteProductC"

flyweight/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ In this example, I create a dynamic table with 3 rows and 3 columns each. The co
5757

5858
The letters are the flyweights and only a code indicating the letter is stored. The letters and numbers are shared many times.
5959

60-
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 which is then used for the space padding.
60+
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.
6161

6262
## Example UML Diagram
6363

flyweight/column.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"A Column which is used in a Row"
1+
"A Column that is used in a Row"
22
from flyweight_factory import FlyweightFactory
33

44
class Column(): # pylint: disable=too-few-public-methods

flyweight/flyweight.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
"The Flyweight which contains an intrinsic value called code"
1+
"The Flyweight that contains an intrinsic value called code"
22

33

44
class Flyweight(): # pylint: disable=too-few-public-methods
5-
"The Flyweight which contains an intrinsic value called code"
5+
"The Flyweight that contains an intrinsic value called code"
66

77
def __init__(self, code: int) -> None:
88
self.code = code

interpreter/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ I then construct the AST manually, by adding a
5555
3. Non-Terminal `Add` row containing the previous Non-Terminal row and the `7`
5656
4. Non-Terminal `Subtract` row containing the previous Non-Terminal row and the `2`
5757

58-
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.
58+
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.
5959

6060
## Output
6161

0 commit comments

Comments
 (0)