wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes MVC question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "MVC question" Watch "MVC question" New topic
Author

MVC question

Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

I just read the Head First - Design patterns and aftrer the Compund Pattern chapter(on the MVC) some question just raise in to my head.

I design the URLyBird 1.3.3 and on the client side I manipulate data but I get this data(s) from the server side, responsable for the data "transport" is in my case the controller - he interacts whit the server, gets the information and packs it in to a model(or it changes the model).The model informs the view about the changesadn so on.

In the Head First - Design patterns on the Compound Patterns , MVC I found :
*The controller implementes the behavior for the view
*The model implements the application logic - the application logic is the code that manages and manipulates the data.

I think this can be true if I have only a pure MVC whitout a relation with an existing system.If you integrate your MVC in to a system then the controller is the "link" between your applicaion(MVC) and the rest of the system.Basic I have somethig like:

user -> view -> controller -> system

if the user interact with the view and :

system -> controller -> model -> view

if the system react(responds).The same logic I found in Max book.

I know that ther are many ways to implement (correct) the MVC pattern but is wrong to make the controller responsable for the "data" transport ?
[ June 01, 2005: Message edited by: Mihai Radulescu ]

SCJP, SCJD, SCWCD, OCPJBCD
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi Mihai,

in Head First Design Patterns (HFDP) the controller is not communicating with the server as you say. Or if so, tell me on which page of HFDP you saw it?

Instead the controller is only communicating with the view and the model.

Regards,
Darya


SCJP, SCJD, SCWCD, SCBCD
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi, Darya,
You are right thats what I try to say in the HFDP the (creamy) controller is communicating

with the view to change the display
with the model to chage its state
with the system/out side world(if you take a look at 529 the user/system does the "Paly the new song" action on controller)

BUT in HFDP the code that manages/manipulates the data is on the model.
If you follow this logic for a if the client musts dispaly data from the server, its model must be able to "manipulates"/transports this information(and this is relativ simple if you hide all behind a proxy).


On Max book the controller "manipulates"/transports the data from server to the cleint(s )and them it builds the model (see the method find(String) VDTableModel from the gui package).

So if in HFDP the model "hides" the comunication between client and server on Max the server does this.

So what you think ? Whitch one is "better" ?
[ June 01, 2005: Message edited by: Mihai Radulescu ]
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi Mihai,

I've seen people here who let the controller do the communication with the system to access the data from data file.

To my opinion it's better done from the model. Because the model is the data representation on the client side and hence has a tight relation to the database.

For me, the controller is simply delegating the view input to the model.

Nevertheless both approaches seem to be valid.

Regards,
Darya
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Darya, I update(more details) my previous post.
And you are right I also think that the model musts comunicate with the data base.
I try to design and maybe I come with an example to this case.

How you find the HFDP ?

P.S: take a look in
JavaRanch Big Moose Saloon � Engineering � OO, Patterns, UML and Refactoring � MVC question

I post a similar question also there and i got some interestiong answers.
[ June 01, 2005: Message edited by: Mihai Radulescu ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MVC question