MCPcopy Create free account
hub / github.com/RefactoringGuru/design-patterns-python / client_code

Function client_code

src/FactoryMethod/Conceptual/main.py:131–143  ·  view source on GitHub ↗

EN: The client code works with an instance of a concrete creator, albeit through its base interface. As long as the client keeps working with the creator via the base interface, you can pass it any creator's subclass. RU: Клиентский код работает с экземпляром конкретного создателя,

(creator: Creator)

Source from the content-addressed store, hash-verified

129
130
131def client_code(creator: Creator) -> None:
132 """
133 EN: The client code works with an instance of a concrete creator, albeit
134 through its base interface. As long as the client keeps working with the
135 creator via the base interface, you can pass it any creator's subclass.
136
137 RU: Клиентский код работает с экземпляром конкретного создателя, хотя и
138 через его базовый интерфейс. Пока клиент продолжает работать с создателем
139 через базовый интерфейс, вы можете передать ему любой подкласс создателя.
140 """
141
142 print(f"Client: I'm not aware of the creator's class, but it still works.\n"
143 f"{creator.some_operation()}", end="")
144
145
146if __name__ == "__main__":

Callers 1

main.pyFile · 0.70

Calls 1

some_operationMethod · 0.80

Tested by

no test coverage detected