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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 4 additions & 4 deletions
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):

0 commit comments

Comments
 (0)