Design: Object Creation Management System
Focus on managing how objects are created in software design. Out of scope are object usage details and business logic unrelated to creation.
Functional Requirements
Non-Functional Requirements
Client | | uses v Creator (Factory/Builder) | | creates v Product (Object)
class Singleton:
_instance = None
def __new__(cls):
if cls._instance is None:
cls._instance = super().__new__(cls)
return cls._instance
obj1 = Singleton()
obj2 = Singleton()
print(obj1 is obj2)class Builder:
def __init__(self):
self.product = Product()
def build_part(self):
self.product.add('part')
def get_product(self):
return self.product
builder = Builder()
builder.build_part()
product = builder.get_product()
print(product.parts)new or constructors?Pass the test and this pattern moves unknown