mirror of
https://github.com/rjNemo/design-patterns
synced 2026-06-06 02:26:40 +00:00
21 lines
610 B
Python
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="")
|