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