• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Client design

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my GUI design so far.Icant wrapp things up so any comments would be great.
You start the client with FBNClient
* FBNClient creates an controller like this:

* MainWindow extends JFrame and creats toolbar and so on.
* ArgumentHandler checks if arguments are ok.
* FlightsModel is the model
* FlightsController uses ArgumentHandler to check if command line args are ok and then sends the arguments to DataBaseConnectionFactory if ok. If not it shows an error message.
Like this:

The DataBaseConnectionFactory gets RemoteDataImpl or LocalDatabaseImpl depending on arguments.
Now, when any action happends in the view I will call the correct method on the controller. Should the controller call stuff on the model(should i setData(Datainterface) on the model with the correct *DataImpl) or on its own *DataImpl....I can get that last bit toghter...
Should the model have a DataInterface or implmenetet it?
Thanks
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


mainWindow.pack();


This code belongs to the View (i.e mainWindow itself), not the Controller.


dataBaseConnectionFactory = new DataBaseConnectionFactory(arguments);


And this code belongs to the Model, not the Controller. The controller responsibility is to listen to user actions and to map them into business methods in the model. So if the controller detects that the "connect to database" button was pressed, the Controller job is to invoke the connectToDatabase() method in the model. The reference to the "dataBaseConnectionFactory" object should therefore be available in the Model, and the controller doesn't need to know anything about it.
Eugene.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, the answer is:
1.The controller should call method on the model, and the method will call stuff on the model with correct DataImpl. Of course, controller can't own DataImpl by itself.
2.The model no need to implement the DataInterface.
How about? :-
 
Jesse Xie
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it better to initiate the application like this:
Model _model = new Model();
Controller _controller = new Controller(_model);
MainFrame _mainFrame = new MainFrame(_model);
//add other necessary controller
_mainFrame.addController(_controller);
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Is it better to initiate the application like this:
Model _model = new Model();
Controller _controller = new Controller(_model);
MainFrame _mainFrame = new MainFrame(_model);
//add other necessary controller
_mainFrame.addController(_controller);
--------------------
An old man from asia.


That looks right, but what is the purpose of the underscores, -- are they communicating some old Asian wisdom? I don't think that Sun Educational Services people will be receiptive of that.
Eugene.
 
Jesse Xie
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hehe
 
Raffe Paffe
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eugene,

The controller responsibility is to listen to user actions and to map them into business methods in the model. So if the controller detects that the "connect to database" button was pressed, the Controller job is to invoke the connectToDatabase() method in the model


Are you sure about this?
I understand it as the contoller listens to the actions, then do whatever business methods it must run on different objects and then populates the model with the correct data. AM i wrong about this?
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
I have a questions, think this fits in this subject....
I have a class called DataConnector which has 2 methods createRemote and createLocal, used by FlightControllers setConnection method, but in the main method of my ClientStartup class i create the FlightController either calling the standard constructor or the constructor which takes the hostname an port as paramters. So i thought about a static method in FlightController to let him also act as a Factory
FlightController.getFlightController(String[] params)
Do you think this is a good idea?
reply
    Bookmark Topic Watch Topic
  • New Topic