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

Function client_code2

src/Composite/Conceptual/main.py:174–188  ·  view source on GitHub ↗

EN: Thanks to the fact that the child-management operations are declared in the base Component class, the client code can work with any component, simple or complex, without depending on their concrete classes. RU: Благодаря тому, что операции управления потомками объявлены в базов

(component1: Component, component2: Component)

Source from the content-addressed store, hash-verified

172
173
174def client_code2(component1: Component, component2: Component) -> None:
175 """
176 EN: Thanks to the fact that the child-management operations are declared in
177 the base Component class, the client code can work with any component,
178 simple or complex, without depending on their concrete classes.
179
180 RU: Благодаря тому, что операции управления потомками объявлены в базовом
181 классе Компонента, клиентский код может работать как с простыми, так и со
182 сложными компонентами, вне зависимости от их конкретных классов.
183 """
184
185 if component1.is_composite():
186 component1.add(component2)
187
188 print(f"RESULT: {component1.operation()}", end="")
189
190
191if __name__ == "__main__":

Callers 1

main.pyFile · 0.85

Calls 3

is_compositeMethod · 0.45
addMethod · 0.45
operationMethod · 0.45

Tested by

no test coverage detected