• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eugene. please help in understanding your snippet on MVC

 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


My understanding is that the method searchFlights in the Model is the Facade to the data/business logic.
I can't identify ( or see the need ) for a controller in your example . Please help identify the Controller ?
regards
[ January 30, 2003: Message edited by: HS Thomas ]
[ January 30, 2003: Message edited by: HS Thomas ]
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Controller's job is to map user actions into business events and to select views. In MVC, the user "gestures" by clicking/selecting, and the controller gets these events and invokes business methods in the model. For example:

Eugene.
[ January 30, 2003: Message edited by: Eugene Kononov ]
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eugene,
That clears a lot for me.
Update Type is used then to indicate to the Views that the Model has changed - a Push notification , I think you mentioned,
as it tells the View exactly what has changed, rather than a Pull notification , which just tells the View that it has changed.
Should this also be part of the Controller ?
Or am I interpreting this wrong ?
regards
[ January 30, 2003: Message edited by: HS Thomas ]
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Update Type is used then to indicate to the Views that the Model has changed - a Push notification , I think you mentioned,
as it tells the View exactly what has changed, rather than a Pull notification , which just tells the View that it has changed.

Right, update type is just an integer that indicates to views what changed in model and what is contained in the delivered data using a model "push". Alternatively, the model can simply ping the views with a parameterless method, and it will be up to views what to "pull" from the model using the model state query methods.

Should this also be part of the Controller ?

What is "this"?
P.S. It will be easier to follow this thread if you fix the first post, -- it screwed the formatting of all posts.
Eugene.
[ January 30, 2003: Message edited by: Eugene Kononov ]
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fixed the first post. Easy when pressed.

By this , I meant the pushing action from Model via Update Type. Should the Controller be responsible also, for telling the View of changes ? So
Model ---> Controller ----> View and
View ----> Controller ----> Model being the
allowable lines of communication .
regards
[ January 30, 2003: Message edited by: HS Thomas ]
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I thought the Controller would be responsible also, for telling the View of changes ?

No, it's not the controller job. In fact, the controller doesn't know if model state changed at all.
Eugene.
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay ,
So View (notifies)<---->(gets parameters) Controller (calls methods on) ----> Model(pushes changes) -----> View (observes) -------> Model is the only place where Controller is involved.
This fits nicely with the MVC triad
(which I can't draw here)
But found another snippet in this Thread
SUN CERT


This has been really useful as MVC is one of the most difficult patterns to understand.
Do you see any problem in merging the DataAccessFacade and the Model as you have it ,
to avoid replicating all those methods?
Du-Oh! How about passing an instance of DAF , Thomas!
Thanks and regards
[ January 30, 2003: Message edited by: HS Thomas ]
[ January 30, 2003: Message edited by: HS Thomas ]
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Do you see any problem in merging the DataAccessFacade and the Model as you have it ,
to avoid replicating all those methods?

Your model can keep a reference to your DataAccessFacade to invoke its (facade's) methods, that's perfectly fine and logical.
Eugene.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eugene Kononov:

Your model can keep a reference to your DataAccessFacade to invoke its (facade's) methods, that's perfectly fine and logical.
Eugene.

Somehow I don't see the function of having a separate "model" and "facade". I've used the facade as the application level model.
The facade looks like this:

The facade has a private reference to a DataConnection object (either LocalDataConnection or RemoteDataConnection) for accessing the Data instance.
The only other model besides my DataFacade that I can think of is the TableModel used by the view's JTable but I don't like the sound of having a javax.swing.TableModel (or whatever it is) be an application level "model" as it pretty much dictates the use of a table and a GUI.

br, Lasse
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Somehow I don't see the function of having a separate "model" and "facade". I've used the facade as the application level model.

That's OK, I just chose to make a finer distinction between a data facade object, whose responsiblity is to provide an easy access to database such as methods close(), getSchema(), and getData(), and the model whose responsibilty is to implement business methods such as bookFlight() and searchFlights(). It seems to me that these two sets of methods belong to two different entities.

but I don't like the sound of having a javax.swing.TableModel (or whatever it is) be an application level "model" as it pretty much dictates the use of a table and a GUI.

I couldn't agree more. Some people use the table model as a model in their application-level MVC, and I think this is a grave mistake.
Eugene.
[ January 30, 2003: Message edited by: Eugene Kononov ]
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eugene and Lasse,
I'd had written a bit of a brain-storm on a Post which I've now deleted as it sounded rather mad.
I'll just go with what I've learnt so far.
P.S. How do you keep all those methods related to the Remote Interface in sync -
In FlightImpl, DataFacade and now, FlightModel ?
I am thinking along the lines of a code generator (say, using Reflection) or a dynamic method call.Using just an interface dictates certain things like the method names , Exception Types thrown ,Method signatures and return types.
This is turning into a nightmare for me.
regards
[ January 31, 2003: Message edited by: HS Thomas ]
[ January 31, 2003: Message edited by: HS Thomas ]
[ January 31, 2003: Message edited by: HS Thomas ]
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lasse ,
It's not clear to me how you maintain the Observer-Observable relationship between the model and View using the Facade as model, as you have shown above.
regards
[ January 31, 2003: Message edited by: HS Thomas ]
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, I left out something important it seems...

[ January 31, 2003: Message edited by: Lasse Koskela ]
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Lasse,
So the above model class implements the DataFacade interface and the business methods in the model class are essentially the facade. I am with you now.
Pretty neat.
Sorry I had overlooked the comment following the DataFacade interface, which would have given a hint.
regards
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may even be the answer to the problem stated in the Post Script in the previous post but one.
I feel I have too many business method implementations which are high maintainence.
Is your DataFacade interface used anywhere else,
e.g. on the server in FlightsImpl?
[ January 31, 2003: Message edited by: HS Thomas ]
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, my suncertify.client.DataFacade is used client-side only. The server-side consists of an RMI-bound factory which creates RemoteDataConnection implementations. The DataFacade has a remote reference to one (Remote/Local)DataConnection, which is basically a wrapper for a Data instance and an accompanying LockManager.
So the client-side facade provides business methods abstracting the underlying Data "interface" (i.e. DataFacade.bookFlight(), DataFacade.getFlights(), DataFacade.getUniqueValues(), etc.).
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Lasse,
that is roughly as I have it now.
regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic