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

Class Abstraction

src/Bridge/Conceptual/main.py:31–47  ·  view source on GitHub ↗

EN: The Abstraction defines the interface for the "control" part of the two class hierarchies. It maintains a reference to an object of the Implementation hierarchy and delegates all of the real work to this object. RU: Абстракция устанавливает интерфейс для «управляющей» части дву

Source from the content-addressed store, hash-verified

29
30
31class Abstraction:
32 """
33 EN: The Abstraction defines the interface for the "control" part of the two
34 class hierarchies. It maintains a reference to an object of the
35 Implementation hierarchy and delegates all of the real work to this object.
36
37 RU: Абстракция устанавливает интерфейс для «управляющей» части двух иерархий
38 классов. Она содержит ссылку на объект из иерархии Реализации и делегирует
39 ему всю настоящую работу.
40 """
41
42 def __init__(self, implementation: Implementation) -> None:
43 self.implementation = implementation
44
45 def operation(self) -> str:
46 return (f"Abstraction: Base operation with:\n"
47 f"{self.implementation.operation_implementation()}")
48
49
50class ExtendedAbstraction(Abstraction):

Callers 1

main.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected