vendredi 25 octobre 2019

How do I reduce two almost identical pieces of code into one?

I have almost two identical logic controllers (the differ in external layouts and input data) and I wonder if I could reduce them into one separate file (or some other method - patterns maybe?). The logic includes creating layouts, promises, showing child views in layouts depending on the responses, event calling. Basic controller stuff. And I wouldn't like to pass a controller or view to a separate file (seems unnatural or unsafe? to me). Maybe You guys have some design patterns or tips on how to achieve my goal?

As a last resort I COULD create separate controller just for managing this logic but if there's another way - I want to know it.

I'm working in backbone and marionette in MVC.

Aucun commentaire:

Enregistrer un commentaire