tags:

views:

45

answers:

1

Hi all, I am a patterns newbie so please excuse this question if it sounds too silly. I am modelling an application which requires a list of identical structures, named CityData, and only one of these structures should be displayed at a time. The view will allow the user to scroll among the various CityData.

Now my problem is: should I have a single model, containing a CityData list and the current displayed index, or should CityData be the model, and a list of it should be included into the controller, which in turn would handle events from the view and update the current displayed item?

I would go for the first one, but the idea of keeping the current displayed index information inside the model just doesn't sound completely correct to me...

A: 

How about keeping the list in the Model but the Index of the currently viewed item in the Controller. In sequence the controller would ask the Model how many CityData objects are available, then get the first CityData object and let the View show the object. The Controller can then handle requests from the user to view other CityData objects, getting them from the Model and in turn letting the View display them.

Huppie
This sounds much better... how fool I didn't get this on my own! Thank you.