Search code examples
model-view-controllerlanguage-agnosticmodelcontrollerperipherals

With MVC, do interactions with autonomous peripherals belong in the Model or the Controller?


Using MVC with an observer pattern, if a user action requires polling a device (such as a camera) for data, should the polling be done in the Controller and the result passed off the Model or should a request be sent to the Model and the Model itself performs the polling.

This question is my attempt to reconcile everything I am reading that touts the "skinny Controllers" maxim with my gut intuition that the Model should only be acting on data not acquiring it.

(Note: This question might be subjective. I'm not entirely sure that there is a one-true-answer to this question. If not, feel free to retag as I will be very interested to hear opinions on the subject.)


Solution

  • It belongs in the controller. The model contains the information and business rules, the controller is essentially the interface to everything that is not the user, information, or a business rule, and the view deals with user interaction.

    One might argue the view could control this as well - the camera model and drivers might be determined by the user, and thus fall under that area.

    But I would not expect the model to have the peripheral interfaces.

    -Adam