mercredi 5 septembre 2018

Design pattern / Architecture hesitation

I need to develop a soft that handles App deployement and upgrade requests like described in the picture below .

enter image description here

What i did, is a double factory factory :

Factory 1 : ApplicationFactory (takes app type as parameter) => gives me an instance of App1Factory or App2Factory... .

App1Factory (specific app factory): Takes a request type as parameter (deploy, upgrade) => return a specific class for that case ( App1Deploy.class / App1Upgrade.class etc...).

App1Deploy / App1Upgrade implements an interface with 3 methode :

  • Validate
  • Start provisioning
  • Close

This way it helps me to keep my rest api controllers clean and i respect a the single responsability priniciple. It alows me also to add easily new request types, new request steps and more apps.

The question :

Is it a good / bad way to do this? Is a specific pattern exists for this case ? Can i do better than this way ?

Thanks

Aucun commentaire:

Enregistrer un commentaire