Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Utility Class MVC

 
Ajit Kumar
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Where does a utility class fit into the MVC Model .
Can i view it as Controller?
For example: I am using a class with get/set methods for its attributes. This class is used as a parameter to some methods. Instead of sending all variables as different parameters to the method, i am storing all variables inside this object and send the object as a parameter.
Can i say that this class acts like a Controller. It does not actually do the controller task( as per the definition atleast ). Or should it be seen as model.
I'd appreciate any comments
AK
 
manish p
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
As you are using the MVC model, I understand that changes to the model would result in property change events being fired to the controller, which would then update the view. Your class that contains all the properties is part of the model.
Why create a method that takes in your holder class (model), on the controller ??
Why not have the controller as a property change listener on the model ? This way the controller will only need to implement the propertyChanged(PropertyChangeEvent e) method. The model would then fire off property change events, where the PropertyChangeEvent would contain the old and new values.
Hope this helps.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I suppose, the class which contain the domain -specific information (attributes and related information/behavior) could be considered as a Model.The Controller should have a reference to the Model and the View, which listens to the events (like actionPerformed of the View,propertyChange of the Model) and delegates the same to the respective components of the Model or sets the value in the View.
It is not a good idea to merge Model and Controller together.You may face problems if you need to re-design (or add new requirements) in the application.If at all you want to merge, you can have View and Controller as one class, but consider this only if the application is small.
Hope this helps,
Sandeep
SCJP2,OCSD(Oracle JDeveloper),OCED(Oracle Internet Platform)
[This message has been edited by Desai Sandeep (edited August 20, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic