mardi 29 octobre 2019

Multiple Conditions and Object Creation using Design Pattern

I am studying design pattern which I can implement to achieve the same purpose as below. However, I am stuck since most of the examples in the net are pretty simple.

I have tried to look at factory method or even strategy method but can't figure out if any of them could be used.

Any suggestion from the guru here?

def checkSomething():
   if ...:
      return True
   else:
      return False

def main(mode, state):
   if checkSomething() == False:
      if mode == False or (mode == True and state == False):
         Class_A().run()
         return False
      else:
         Class_B().run()
         obj_c = Class_C()
         return obj_c

Aucun commentaire:

Enregistrer un commentaire