I am in the process of implementing the Abstract Factory Design pattern. The scenario that I considered is given below.
. The article and picture credits come from https://medium.com/@hitherejoe/design-patterns-abstract-factory-39a22985bdbf. I am trying to implement in Python and I am stuck and couldn't move forward due to the below reason
When you define ThemeFactory as an interface in Python, then whatever the methods you define in ThemeFacory has to be implemented in concrete classes such as LightTheme and DarkTheme.
But my concern is, is there any necessity to provide an implementation to method createLightTheme
in Concrete class DarkTheme
vice-versa. Should I need to redesign the complete architecture?
import abc
class ThemeFactory(metaclass=abc.ABCMeta):
@abc.abstractmethod
def createdarktheme(self):
pass
@abc.abstractmethod
def createlighttheme(self):
pass
class DarkTheme(ThemeFactory):
def createdarktheme(self):
print('Hello created dark theme')
def createlighttheme(self):
pass
if __name__== '__main__':
dark = DarkTheme()
dark.createdarktheme()
Aucun commentaire:
Enregistrer un commentaire