design-patterns/creational/builder/products.py
Ruidy 7b0e4a5801
Singleton (#6)
* singleton example

* chore: enforce style guidelines
2020-09-14 21:27:39 +02:00

21 lines
610 B
Python

from typing import Any
class Product1:
"""
It makes sense to use the Builder pattern only when your products are quite
complex and require extensive configuration.
Unlike in other creational patterns, different concrete builders can
produce unrelated products. In other words, results of various builders may
not always follow the same interface.
"""
def __init__(self) -> None:
self.parts = []
def add(self, part: Any) -> None:
self.parts.append(part)
def list_parts(self) -> None:
print(f"Product parts: {', '.join(self.parts)}", end="")