I have an MVC app, which has multiple views that give overviews (from different angles) on items.
For now, let's just call these views
- View1
- View2
- ...
- ViewX
They all use the same Model Collection as a basis
As of now I have one controller per view (View1Controller, View2Controller, ...), and furthermore, I have ItemEditView and ItemEditController for the item edit window.
When certain interactions occur inside the numbered views, the same actions have to be done:
- Action Chain 1: Boil down the clicked position/button to two values, check whether these two values allow to make a new item, if so, open the ItemEditView to create a new item.
- Action Chain 2: Check whether this item may be shown, if so, open ItemEditView to edit the item.
- Action Chain 3: Check whether this item may be changed, if so, update it based on the position it was dragged to.
How would I best split this into functions and controllers?
As of now, the function View2Controller.ItemClicked()
calculates some additional parameters required by View1Controller, and then calls View1Controller.ItemClicked()
... I guess this is a terrible mess, but where would I put common functions of all ViewXControllers?
Or should I put all functions of all the Views into a common controller?
View2Controller extends View1Controller
maybe