Welcome to Dream.In.Code
Getting Help is Easy!

Join 135,937 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,678 people online right now. Registration is fast and FREE... Join Now!




Controller class responsibilities

 
Reply to this topicStart new topic

Controller class responsibilities

ojve
20 Oct, 2007 - 08:40 AM
Post #1

New D.I.C Head
*

Joined: 11 Oct, 2007
Posts: 7


My Contributions
Studying for an exam in OOA/D and I was wondering whether a class implementing the controller pattern usually also would handle information going the other way(eg. from the domain model to the UI)? If no, how is this usually implemented?

thx!
//T
User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Controller Class Responsibilities
20 Oct, 2007 - 09:08 AM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 3,983



Thanked: 16 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
essentially yes.

the model contains the bare code:
algorithms, encryption, etc --> these things are platform independent

the view or UI:
has a current ability to display the program and/or output.
this UI could be dependent depending on the implementation, but all views will share object names and references to be used with the controller

*These 2 code blocks could be multiple classes, and they are completely independent of each other, and have no idea that the other even exists.

The Controller unites the model and UI:
containing code to grab pointers or references to buttons, textareas, mouse clicks, etc. It will then respond to the User Interface by calling the model with the supplied information.
The model should handle on it's own and error checking related to bad input into an algorithm, the controller handles errors which result in passing incorrect variable or type information. Each is technically independent, but the controller itself has access to the other 2.

a classic main method for a controller class is: (java example)
new Controller(new UI("title"),new Model());


Hope that was specific enough for you smile.gif
User is offlineProfile CardPM
+Quote Post

ojve
RE: Controller Class Responsibilities
20 Oct, 2007 - 11:47 AM
Post #3

New D.I.C Head
*

Joined: 11 Oct, 2007
Posts: 7


My Contributions
QUOTE

*These 2 code blocks could be multiple classes, and they are completely independent of each other, and have no idea that the other even exists.

The Controller unites the model and UI:
containing code to grab pointers or references to buttons, textareas, mouse clicks, etc. It will then respond to the User Interface by calling the model with the supplied information.
The model should handle on it's own and error checking related to bad input into an algorithm, the controller handles errors which result in passing incorrect variable or type information. Each is technically independent, but the controller itself has access to the other 2.



Will the UI always go through the Controller? Even when just gathering information to display?

and thank you, that was great help smile.gif

//T

EDIT: And also, another question, if you don't mind. I have a small app in C#. One with a couple of different forms. Should the forms all have direct contact with the controller or send their messages via some central class, like the form that created them. For example I have form SettingsForm that is launched by the main window(or should it be launched by the controller?). Should this window send it's messages through the main window to the controller(this seems to support low coupling better) or directly to the controller(this, to me, seems to better support high cohesion).

Thx

This post has been edited by ojve: 20 Oct, 2007 - 11:59 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:36AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month