| Author |
general design review
|
Raffe Paffe
Ranch Hand
Joined: Feb 24, 2003
Posts: 92
|
|
Here is my design. Any comments would be great! FBNClient.java The client start class. Constructs an ArgumentHandler from the commanline arguments and passes it on to the FlightsController. FlightsController.java Creates the FlightsModel and the MainWindow like this: flightsModel = new FlightsModel(arguments); mainWindow = new MainWindow(flightsModel);. Creates the "reaction" classes and adds them to corresponing metohds in the MainWindow like this for example: FlightsModel.java Extends Observable. FlightsModel has business methods such as search and reserve.It uses the DataBaseConnectionFactory to get a a database. dataBaseConnectionFactory.getData() returns a DataInterface so FlightsModel doesnt know if it works on a local or remote connection. FlightsModel also has methods like getTableHeader and getTableData to support MainTable and getOrigins,getDestinations and getRecord to support MainWindow. LocalDatabaseImpl.java Implements DataInterface. Has a Data which it calls methos on like for example database.modify(newData); MainTable.java Extends AbstractTableModel. Handles the table and has methods like getColumnCount,getValueAt and updateTableData. MainWindow.java Extends JFrame implements Observer.The main window of the application.Setup of all GUI components.Sign us up as Observer to the FlightsModel. Create the menu bar at the top with a file and help menu. Below that a toolbar with Search,Reserve and help as options.Below that two labels (origins and destinations) and the correspodning comboboxes.Below that the MainTable. Contains methods for actions to be added from the FlightsController like this: ReserveController.java ReserveController is the controller (MVC) in reservation part of the interface. Invoked from the FlightsController when the reserve button is pressed in the MainWindow. Opens the ReserveDialog. Creates the "reaction" classes and adds them to corresponing metohds in the reserveDialog just like FlightsController. ReserveDialog.java Extends JDialog.This is where you reserve a number of seats on a flight. Contains methods for actions to be added from the ReserveControllerlike this: suncertify.db Data.java The one provided by Sun. Add the criteriaFind, lock and unlock.Changed deprecated method calls. There is a Data for each client to keep track of the clients. Each Data is mapped to a recordId in a HashMAp in a synchronized way. DataBaseConnectionFactory.java Takes an ArgumentHandler to determin if in local or remot mode.See below. getData() returns a DataInterface. DatabaseException.java The one provided by Sun. DataInfo.java The one provided by Sun. DataInterface.java Same methods as Data. FieldInfo.java The one provided by Sun. suncertify.server DataInterfaceFactory.java Extends Remote and has only one method: DataInterface getDatabaseInstance(String dbName) DataInterfaceFactoryImpl.java Extends UnicastRemoteObject and implements DataInterfaceFactory. startServer() binds to the registry. getDatabaseInstance(String dbName) returns a DataInterface to a client like this: new RemoteDataImpl(new Data(dbName)); FBNServer.java Server start class. Creats DataInterfaceFactoryImpl and calls startServer(); RemoteDataImpl.java Extends UnicastRemoteObject implements DataInterface and Unreferenced. Has a Data which it calls methos on like for example database.modify(newData). suncertify.util ArgumentHandler.java ArgumentHandler handels the command line arguments.ArgumentHandler determins what mode to use: local or remote. Wow, a lot. Again please comment!!! :-) [ April 16, 2003: Message edited by: Raffe Paffe ] [ April 16, 2003: Message edited by: Raffe Paffe ]
|
Free software is a matter of liberty, not price.
|
 |
John Smith
Ranch Hand
Joined: Oct 08, 2001
Posts: 2937
|
|
FlightsModel also has methods like getTableHeader and getTableData
I don't think it's a good idea to have methods such as getTableHeader() and getTableData() in the Model. The Model is supposed to model the business, and it should not hint to any particular View. If the rendering component in the View changes from JTable to something else (a chart, a listbox), the Model should not be required to change. Eugene.
|
 |
Raffe Paffe
Ranch Hand
Joined: Feb 24, 2003
Posts: 92
|
|
I don't think it's a good idea to have methods such as getTableHeader() and getTableData() in the Model.
So, i should rename them or were should a get this information? Anything else in the design that was bad/good? Thanks for your comment Eugene.
|
 |
Raffe Paffe
Ranch Hand
Joined: Feb 24, 2003
Posts: 92
|
|
Please, any comments would be great! Anything totally wrong here?
|
 |
Wagner Danda Da Silva Filho
Ranch Hand
Joined: Mar 21, 2003
Posts: 80
|
|
Originally posted by Raffe Paffe: DataBaseConnectionFactory.java Takes an ArgumentHandler to determin if in local or remot mode.See below. getData() returns a DataInterface.
Very interesting design. With this factory you can use local or remote classes in the same way. Did you have any trouble using this pattern?
|
SCJP, SCWCD
|
 |
Max Habibi
town drunk ( and author)
Sheriff
Joined: Jun 27, 2002
Posts: 4118
|
|
Originally posted by Eugene Kononov: I don't think it's a good idea to have methods such as getTableHeader() and getTableData() in the Model. The Model is supposed to model the business, and it should not hint to any particular View. If the rendering component in the View changes from JTable to something else (a chart, a listbox), the Model should not be required to change. Eugene.
I think it's ok. After all, the Model is specifcally for a JTable, so it's ok if it add JTable friendly methods. M, author The Sun Certified Java Developer Exam with J2SE 1.4
|
Java Regular Expressions
|
 |
John Smith
Ranch Hand
Joined: Oct 08, 2001
Posts: 2937
|
|
Max: I think it's ok. After all, the Model is specifcally for a JTable, so it's ok if it add JTable friendly methods. My point is that the Model in application level MVC should not be specifically for JTable, or for any other visual widget. Raffe already has a model for the JTable, and yes, put whatever JTable-related methods in there. But do not contaminate the business logic in the application Model with the presentation logic. Eugene.
|
 |
Ta Ri Ki Sun
Ranch Hand
Joined: Mar 26, 2002
Posts: 442
|
|
Originally posted by Eugene Kononov: Max: I think it's ok. After all, the Model is specifcally for a JTable, so it's ok if it add JTable friendly methods. My point is that the Model in application level MVC should not be specifically for JTable, or for any other visual widget. Raffe already has a model for the JTable, and yes, put whatever JTable-related methods in there. But do not contaminate the business logic in the application Model with the presentation logic. Eugene.
maybe thats why the assignment changed, I'm assuming Raffe's assignment is different, because mine says in no less than 5 ways that I should use MVC, some subtle and others not so subtle, one of them being that the company plans to develop a web-based system based on the system I build, and that they hope to be able to use some of the code, now the GUI obviously goes, and the controller is given the boot in favour of a front controller because the gui controller is built around the view in a great many ways making it useless for any other front end, that just leaves the model, so if I cant at the end of my assignment slap Struts onto my model without any changes I wont submit my assignment, because I'll have failed technically by not provided anything that can be re-used in this web-based system they mention, and I'll have BS'd myself into an MVC that defies its purpose
|
 |
Raffe Paffe
Ranch Hand
Joined: Feb 24, 2003
Posts: 92
|
|
Wagner da Silva : No it works fine! Eugene:
Raffe already has a model for the JTable,
No, I have only one model for my GUI. Should I have more than one?
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10826
|
|
Hi Raffe, The model represents enterprise data and the business rules that govern access to and updates of this data. (From http://java.sun.com/blueprints/patterns/MVC-detailed.html) Or, as Eugene put it:
My point is that the Model in application level MVC should not be specifically for JTable, or for any other visual widget.
The problem is extensibility and / or reuse. If your model sends a TableModel to it's observers then its reuse may be limited. The model may well be used by some class that has no knowledge of a TableModel (printer, wap device, ...). Does this make sense? Regards, Andrew
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
Raffe Paffe
Ranch Hand
Joined: Feb 24, 2003
Posts: 92
|
|
Andrew : Yes it makes sense. But my model only returns a String [] and a String [][] in my case. So I wonder if i should change the names of my methods to something like getColumnaNames and getData. What do you think? Thanks Andrew p.s Can you reserve an exam date before you have submitted the application? d.s
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10826
|
|
Hi Raffe, Yes, I think it is a good idea to change the method names - if the examiner is also confused into thinking the model is wrong then it might cost you marks. I think the only requirement is that you submit the assignment before you sit the exam. So there should be no problem with reserving the exam before you have submitted the assignment. From other posts in this forum it even appears that this requirement is not strictly enforced - a number of people booked their exam, then attempted to upload their assignment and had troubles with the upload - by the time the problem was sorted out, they had already sat their exam. They still passed. Regards, Andrew
|
 |
 |
|
|
subject: general design review
|
|
|