Search code examples
design-patternsmvp

MVP - Supervising Controller


Can someone tell me what component in MVP - Supervising Controller variation has the responsibility for implementing logic related to the enablement/disablement of UI elements?

For example, I have a view that has a checkbox and a number of textboxes. Now 2 of the text boxes should only be enabled if the checkbox is checked.

Should the logic to control this be the responsibilty of the presenter or the model?


Solution

  • Supervising Controller assumes that

    • View interacts with model for simple data binding
    • View is updated by Presenter and through data binding

    So basically in order to find responsible component you need to identify who has enough information to do the update. If checked state of checkbox is directly mapped to Model then View is the right place to do it through data binding. If on the other hand the state is calculated by presenter as a result of reacting to user interaction then you can update View from Presenter.