I am building a framework, below is the class design using python. The subclass will only provide the necessary stuff and the order of execution will be defined by the superclass, does this pattern matter?
class A:
def do_a():
pass
class B:
def do_b():
pass
def AbstractClass:
def __init__(self):
self.a = self.register_a()
self.b = self.register_b()
@abstract
def register_a() -> A:
raise NotImplementedError
@abstract
def register_b() -> B:
raise NotImplementedError
def template(self):
a.do_a()
b.do_b()
def Concrete(AbstractClass):
def register_a():
return A()
def register_b():
return B()
Aucun commentaire:
Enregistrer un commentaire