samedi 31 octobre 2020

Screenplay pattern - common methods among actions

I'm currently trying out the screenplay pattern. My question regards how to deal with common methods across several actions?

So as an example I have a method for my homepage actions that looks if a checkbox is checked. If the checkbox is not checked it checks the checkbox. If it is checked it does nothing and move to the next step. Now this type of method is needed in other action classes aswell.

My question is what is the best approach to keeping DRY in this case? Should I implement a helper class and create an instance of that class in the action classes that require that method? Or should I create a base class and have my action classes inherit from that? Or is there a better approach altogether?

I want to work according to SOLID but i'm not sure what the best approach is in this case.

Aucun commentaire:

Enregistrer un commentaire