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

Client design

 
Raffe Paffe
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • 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
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • 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.
 
Jesse Xie
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
hehe
 
Raffe Paffe
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • 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?
 
Mario Zott
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic