Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MVC pattern again - with one class per view  RSS feed

Venita Glasfurd
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've seen quite a few posts here regarding the MVC pattern, but haven't been able to find the answer to my doubts.
I have one class for each view
-the Search frame
-the Result frame
-the Reserve Flights frame
On click of the Search button, the search frame creates an instance of the Result frame.
on click of Reserve button on the Result frame, an instance of the Reserve frame is created.
Now, when designing the controller,
1. should I have a controller for each View? In this case, where can I instantiate each contoller?
I considered instantiating the controller for my Result frame in the Search frame class and so on, but this goes against the idea that a GUI shouldn't know a controller( even if the controller in this case is not for itself, but for a succeeding frame - is this correct?).
2. Should I have just one controller for all the views?
This means that the one Controller class should have references to all the views(search, result and reserve frames). Again, the reference for each frame can be set into the Controller only from the preceding frame.
Or maybe I should instantiate all my frames along with their respective controller(s), in the main program itself, and show them only at the appropriate moments. Is there any other way of approaching this?
Mark Spritzler
Posts: 17309
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this case I like one controller for all the Frames.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!