views:

128

answers:

3

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.)

+1  A: 

The Controller should perform the polling. The Model is a snapshot of state in my mind, so the camera states should be passed from the controller to the Model.

jmcd
+1  A: 

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 Davis
+1  A: 

you could add a thin service layer below controller and above model, this enables you to put all your access to periphery code in one place

miceuz