• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC pattern questions

 
Akash Singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have ConnectionView and ConnectionController classes.
Connection View allows user to select local/remote mode (a radio group). After selection, user enters for ex. file name for local mode; dns name and port no for remote mode to connect to FBN system. This class has hook methods for all items those can listen for events. It also has set/get and enable/disable methods. These methods are called from ConnectionController.
ConnectionController class has implmentation for all hook method and calls
set/get and enable/disable methods on ConnectionView class.
Questions:
1. I do not have seperate model class for this. This does not have a scope for a seperate model class; does it ? Can i say that class combines view and model both ?
2. Can View have set/get methods ?
3. In some places(books or sample code) , listener has been implemented in the same file which has view class. What is good way; to seperate the controller in sepertate file, instead of in the same file having private/annonymous classes as implementation of listener ?
4. Am i right, if i say following for couplings of MVC classes.
Model does not have any reference of View and Controller.
View does not have reference of Contoller, but can have ref of Model.
Controller must have reference of View, and can have reference of Model.

Regards,
Shashi
 
Akash Singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Come on guys, please clarify my doubts on MVC. Its really stoping me to go ahead further.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Akash,
This sounds more like the View Helper design pattern.
Note that you do not have to use the MVC pattern (there is no "must" requirement for it).
Can View have set/get methods ?

Yes, this is possible. You might want to consider whether the getter / setters are there to help the view do it's work, or whether you are trying to have the view act as the model though.
What is good way; to seperate the controller in sepertate file, instead of in the same file having private/annonymous classes as implementation of listener ?

Take a look at Eugene Kononov's suggestion for an MVC
Am i right, if i say following for couplings of MVC classes.
  • Model does not have any reference of View and Controller.
  • View does not have reference of Contoller, but can have ref of Model.
  • Controller must have reference of View, and can have reference of Model.


  • The model may be observable, in which case it has references to all it's observers. It does not know anything about the observer other than the fact it is an observer.
  • View can have references to both model and controller, but may not need either
  • Yes


  • Regards, Andrew
     
    Akash Singh
    Ranch Hand
    Posts: 80
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Again, Andrew.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic