mercredi 11 mai 2016

Does this scenario call for a Factory Pattern?

I have a Model which can be created across different controllers or classes. An example of this is the scenario that AController may need to create the model using the same logic in ModelController. Some facts about creating this model are thus:

  • it does not depend on any other model in my domain space.
  • it contains more logic than the usual (new Model($params))->save()

Does this call for a ModelFactory or is it okay to duplicate the code? How do I go about this?

I know this calls for some sort of abstraction; but which exactly?

Aucun commentaire:

Enregistrer un commentaire