Answer the question
In order to leave comments, you need to log in
Why do we need abstraction in OOP?
Why is the pattern implemented through the abstraction tyts ?
Couldn't you just write these methods in a regular class?
Answer the question
In order to leave comments, you need to log in
Can.
Why? So that objects are not created on the basis of an abstract class.
So that the interpreter prompts you that you have not described such and such a method (which is abstract).
There are no interfaces in Python, so you have to declare an abstraction without behavior like this.
Why is abstraction needed - then, so that the code is not tied to a specific object, but tied to some boundaries of behavior (which is abstraction) - in this case, to some SUbject
class Observer(ABC):
@abstractmethod
def update(self, subject: Subject) -> None:
"""
Получить обновление от субъекта.
"""
pass
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question