Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC Implementaion!

 
Vikas Sood
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
It has been a long time since i last wrote or interacted in this forum.Am stuck at the same point for a long time now,that is GUI.(lack of time also is to blame,but not much time left before expiry of coupon so i have taken to finish this assignment now.)
Is the following implementation looks ok :
CheckboxModel TableModel
| |
GUI >> Controller >> FlightModel >> FlightFacade >>DataClient >> Data/RemoteData
Am I in the right direction.
Kindly Comment
VikasSood
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To me the FlightModel, FlightFacade and DataClient were one in the same.
as in
GUI CONTROLLER DATAFACADE
DataFacade wraps around a DataAccess interface. Meaning either a DataAccessRemote or a DataAccessLocal, depending on mode. The two DataAccess classes have reference to the Data class.
What are you using a checkbox for?
Otherwise you are in the right direction
As far as the assignment, there is no expiration date.
Mark
 
Vikas Sood
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
Thanks for ur reply i have somemore doubt can you comment.
As Per Sun's Specs, i think we need to have an implementation of all the public methods of DataAcess interface on the client side,that is what i am doing in the DataClient class.But
What i remember from my earlier discusion couple of months back in a thread on Facade pattern use,We discussed on hiding the overall implementation in DataClient from client side by building FlightFacade of sorts that acts as a wrapper around DataClient and makes available only the required methods from DataClient.I think my FlightFacade will also act as Model for my client view also.

My question is do i need this kind of FlightFacade or will it be appropriate to just have a single DataClient, as the DataClient is already acting as a Facade (But then the Facade will have access to all the DataAcess Interface methods,and is it really acting as a Facade at all?).
IS This Right:
GUI >> Controller( TableModel& ComboboxModel <Mis-spelt earlier> As Inner classes) >> FlightFacadeModel >> DataClient ----->etc
Kindly Comment
Regards,
VikasSood
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GUI >> Controller( TableModel& ComboboxModel <Mis-spelt earlier> As Inner classes) >> FlightFacadeModel >> DataClient ----->etc

That is right, the DataClient is the implementation class of the DataAccess interface. One DataClient is for local, and one for Remote.

As Per Sun's Specs, i think we need to have an implementation of all the public methods of DataAcess interface on the client side,that is what i am doing in the DataClient class.

I think semantics is playing a part in your interpretation of the Sun Spec's. Even thought the DataAccessRemote class resides on the server, you will have a stub of this on the client, therefore you are meeting their requirements. And in local mode the DataAccessLocal resides on the client.
So in both cases you have met the requirement. That is why I am saying that the DataClient class you have is a redundancy, and unecessary.
Hope that helps.
Mark
 
Vikas Sood
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark
Thanks for ur reply.
To further our discussion i have some thoughts to follow:
I think I have not beeen able to explain my architecture to the fullest,let me reput it again.
GUI >> Controller >> FlightModelFacade
>>
DataClient (Makes use of DataConection Factory which based on client preference connects to Data localy or remotely ,implements DataAccess interface.
>>
(For Local Mode) Communicates directly to Data // (For Remote Mode) Communicates to Data through Network using rmi and an individual copy of RemodeData .


That is right, the DataClient is the implementation class of the DataAccess interface. One DataClient is for local, and one for Remote.

I dont have two implementations of DataClient as you have suggested.I have just made use of a factoryclass for providing a reference to Data or RemoteData as per user inputs.My DataClient is acting as DataAccessLocal & DataAccessRemote as per choices made.Is it all right to go this way.
Kindly Comment
VikasSood
 
Vikas Sood
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I think Mark has left for the training he was to attend, can anybody else comment on my implementation.I am stuck at the moment.
VikasSood
[ April 14, 2003: Message edited by: Vikas Sood ]
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12012
216
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vikas,
I am trying to understand your question. You said:
I dont have two implementations of DataClient as you have suggested.I have just made use of a factoryclass for providing a reference to Data or RemoteData as per user inputs.My DataClient is acting as DataAccessLocal & DataAccessRemote as per choices made.Is it all right to go this way.

I think the usual way people are coding this is to design the interface, then code two classes which implement this interface - one for local access (which for this topic I will call "LocalDataClient"), and one for remote access (which for this topic I will call "RemoteDataClient").
There are (at least) two ways of proceeding from there:
  • Some people have a factory class to provide access to these two classes,
  • others just code to the interface and create one of these two classes in their Model dependant on the user's choice.


  • Are you saying that you have implemented the second choice or have you gone for a third choice -
    combining the LocalDataClient and RemoteDataClient into one class?
    Regards, Andrew
     
    Mark Spritzler
    ranger
    Sheriff
    Posts: 17278
    6
    IntelliJ IDE Mac Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yes Vikas. As long as they weren't two different classes. You DataClient is actually the instance of DataAccessRemote or DataAccessLocal.
    Good Job
    Mark
     
    Vikas Sood
    Ranch Hand
    Posts: 109
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Mark / Andrew,
    I think i have not been able to explain my design to you in its entirity.Let me explain it agian:
    GUI >> Controller >> FlightModelFacade
    >>
    DataClient (Makes use of DataConection Factory which based on client preference connects to Data localy (In Local Mode i dont have any LocalDataAccess class as you have been suggesting,my DataClient class is directly communicating with Data class for local access.Behaves like LocalDataAccess class) or remotely (DataClient Connects to RemoteDataAccess which in turn uses Data class for network mode),RemoteDataAccess and DataClient both implements DataAccess interface.The same interface is also implemented by Data class.
    >>
    (For Local Mode) Communicates directly to Data // (For Remote Mode) Communicates to Data through Network using rmi and an individual copy of RemodeData .
    As Andrew has suggested i am having a third kind of implementation, Maybe.Kindly Comment.
    VikasSood
     
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander
    Pie
    Posts: 12012
    216
    C++ Firefox Browser IntelliJ IDE Java Mac Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Vikas,
    That looks fine.
    What is important is that your client is connecting to the Factory, and always calling the same methods within it. That is, there is nothing in your client flight booking code that behaves differently for local vs remote connections.
    How many classes exist between the concrete class used by the factory and the end classes that perform your actions is irrelevant.
    Regards, Andrew
     
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander
    Pie
    Posts: 12012
    216
    C++ Firefox Browser IntelliJ IDE Java Mac Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Vikas,
    That looks fine.
    What is important is that your client is connecting to the Factory, and always calling the same methods within it. That is, there is nothing in your client flight booking code that behaves differently for local vs remote connections.
    How many classes exist between the concrete class used by the factory and the end classes that perform your actions is irrelevant.
    Regards, Andrew
     
    Vikas Sood
    Ranch Hand
    Posts: 109
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Andrew,
    Yes,my client code uses the same method in factory for accessing data ,it is irrelevent that mode is local or remote.
    I hope am on the right track.
    VikasSood
     
    Vikas Sood
    Ranch Hand
    Posts: 109
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    HI Mark/Andrew
    I was out of town so didnt get much chance to further this dicussion,but am now:
    As i have got the architecture more or less ready,i am now working on the internal aspects of my design.
    My Gui is having hook methods of sorts as Mark has suggested in no. of other posts.
    Controller is having a reference of both view(FBNGUI) and model(FBNFacadeModel)
    Events generated in view are received by controller(FBNController) which in turn calls some relvent method in model which has a reference of DataClient to get the job done.
    As the model receives the response of request sent to DataClient,it is made available to controller by default as it has a reference to model.Controller in turn updates table model,which updates view.
    Am i going right over here.Kindly comment.
    VikasSood
    [ April 30, 2003: Message edited by: Vikas Sood ]
     
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander
    Pie
    Posts: 12012
    216
    C++ Firefox Browser IntelliJ IDE Java Mac Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Vikas,

    As the model receives the response of request sent to DataClient,it is made available to controller by default as it has a reference to model.Controller in turn updates table model,which updates view.

    Huston we have a problem.
    The model is supposed to be modelling the enterprise data for any view that wants to access it.
    To give a concrete example (although not relevant for our assignment), you could have one "view" which is the screen display for picking flights, and one "view" which is a tickertape display of flights that are close to capacity booking.
    Consider what happens if you book all the available seats in a given flight.
    The user selects the flight from the view, and inputs the number of seats requested. This information is then sent to the controller, which in turn passes it to the model. So far so good.
    The problem is what happens after that ... under your scenario, your view got updated, but the tickertape view did not receive any such update.
    Ideally what should have happened is that each of the views should have informed the model that they wish to observe any changes that happens to the data held by the model. Then, when any class sends a command to the model which will change the data, the model will inform all the classes which have registered with it that a change has occurred.
    This is the Observer - Observable pattern.
    I have come dangerously close to giving an entire solution here, so I am stoping at this point.
    Have a think about that, and see if you can find anything in standard Java that will give you this sort of functionality.
    Regards, Andrew
     
    Vikas Sood
    Ranch Hand
    Posts: 109
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Andrew,
    Thanks for your reply.
    I had observer-observable in mind for this scenario earlier.I have also seen Eugene's posts on this topic over here.
    But what i was trying to do was to decouple View from Model,according to my interpretation of MVC the only class having knowledge of them both together should be the Controller only.Which captures events from Views and gets the work done through Model.And as for other Views getting notified of the change in Model,its the responsibility of Controller.
    Kindly Comment.
    VikasSood
    [ May 02, 2003: Message edited by: Vikas Sood ]
     
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander
    Pie
    Posts: 12012
    216
    C++ Firefox Browser IntelliJ IDE Java Mac Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Vikas,
    This is one of the more confusing aspects of MVC, however there is a link between the Model and the View.
    I recommend you take a look at the Sun description of MVC at Sun's blueprints page (MVC)
    You will see that the View can get stateful information from the Model directly (are you connected, what are the column names...).
    Also the Model updates the View (Observer-Observable) whenever it's data changes (result of criteriaFind...)
    For both of these, the overhead of going through the Controller is not warranted.
    However if the View creates some sort of event (book a seat, find this criteria for me ....) then it should pass the event to the Controller. The controller then passes it to the correct Class (or classes) to deal with it.
    Under your concept of decoupling the View from the Model, you would still need to register the Controller as an Observer of the View. Otherwise you still have the same potential problem I mentioned earlier - one or more controllers (views) not getting updated when the model changes.
    Regards, Andrew
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic