added brief descriptions of creational patterns
This commit is contained in:
12
README.md
12
README.md
@@ -501,6 +501,8 @@ ___
|
|||||||
|
|
||||||
##### Builder Pattern
|
##### Builder Pattern
|
||||||
|
|
||||||
|
Separate object construction from its representation.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pypattyrn.creational.builder import Builder, Director
|
from pypattyrn.creational.builder import Builder, Director
|
||||||
|
|
||||||
@@ -569,6 +571,8 @@ print(repr(house)) #Floor: More than one | Size: Small
|
|||||||
|
|
||||||
##### Factory Pattern
|
##### Factory Pattern
|
||||||
|
|
||||||
|
An interface for creating an object.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pypattyrn.creational.factory import Factory # This is just an interface
|
from pypattyrn.creational.factory import Factory # This is just an interface
|
||||||
|
|
||||||
@@ -607,6 +611,8 @@ dog.speak() # 'woof'
|
|||||||
|
|
||||||
##### Abstract Factory Pattern
|
##### Abstract Factory Pattern
|
||||||
|
|
||||||
|
Create an instance from a family of factories.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pypattyrn.creational.factory import Factory, AbstractFactory
|
from pypattyrn.creational.factory import Factory, AbstractFactory
|
||||||
|
|
||||||
@@ -687,6 +693,8 @@ fly.fly() # 'fly'
|
|||||||
|
|
||||||
##### Object Pool Pattern
|
##### Object Pool Pattern
|
||||||
|
|
||||||
|
Provide a pool of instantiated objects which can be checked out and returned rather than creating new objects all the time.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pypattyrn.creational.pool import Reusable, Pool
|
from pypattyrn.creational.pool import Reusable, Pool
|
||||||
|
|
||||||
@@ -723,6 +731,8 @@ assert dog_one.sound == dog_four.sound
|
|||||||
|
|
||||||
##### Prototype Pattern
|
##### Prototype Pattern
|
||||||
|
|
||||||
|
Clone an object to produce new objects.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pypattyrn.creational.prototype import Prototype
|
from pypattyrn.creational.prototype import Prototype
|
||||||
|
|
||||||
@@ -760,6 +770,8 @@ assert point_four.distance_to(point_three) == 0
|
|||||||
|
|
||||||
##### Singleton Pattern
|
##### Singleton Pattern
|
||||||
|
|
||||||
|
Ensure that only a single instance of a class exists.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pypattyrn.creational.singleton import Singleton
|
from pypattyrn.creational.singleton import Singleton
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user