aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes GUI design and future extensions... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "GUI design and future extensions..." Watch "GUI design and future extensions..." New topic
Author

GUI design and future extensions...

Klaas van Gelder
Ranch Hand

Joined: Jul 08, 2004
Posts: 100
Hi all,

I am still struggling with the GUI implementation. In my first thougts, I considered the TableModel as the "model" in the MVC architecture.
But in fact, the TableModel is tightly coupled with a JTable component and therefore part of the Swing-based view.
If the application should be extended, for example, having a Web-based interface, we have nothing to do with a JTable and the corresponding TableModel. The view now would be a servlet or JSP page...
Therefore, I think that the TableModel class should be considered as part of the View. A separate FlightDataModel class would then be necessary.

The same counts for implementing the Controller actions using the javax.swing.Action class. This class is useful when we want to attach the same functionality to menu items and (toolbar)buttons, but again is completly bounded to the use of a Swing gui.

So my question is, can we assume that only Swing clients are used for the application, or should we make the Controller and Model classes completly swing-independent ? If we do, we can still use the swing Action classes, but these would be part of the View instead of the Controller.
The Controller now should contain methods for searcing and booking flights, which recieve some GuiInterface parameter to obtain the search/booking info from the Gui.

View:
MainWindow class, Action classes, TableModel class

Controller class:
Methods for searching and booking flights, recieving a ViewInterface parameter and filling the Model.

Model class:
Contains a private array variable containing the records that may be viewed (= a subset of all records after a search action), a getter method which returns these records, and a method that notifies the Views (called by the controller).


Am I right in my considerations ? Please give my any feedback... :-)
Regards, Klaas
[ August 01, 2004: Message edited by: Klaas van Gelder ]

"What you don't know, can't help you"
SCJP (81%), SCWCD (81%), SCJD (354/400), SCBCD (85%)
Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
I've implemented the gui on MVC, a beautiful sight to behold. But then I just trashed it, because I realized that I need to do a simple GUI. I now want to minimize the number of classes I need to implement.

My GUI class is GUI (extends JFrame)
Controller class is Client (extends Object and knows how to talk via RMI to the server)
Model class is DataModel (extends DefaultTableModel)

I've organized my packages into four:

suncertify.client
suncertify.server
suncertify.db
suncertify.remote

I am going to make the gui as simple as possible. It's not worth it to create something complex and then discover that the complexity has outgrown the scope of the project.


Anton Golovin (anton.golovin@gmail.com) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
Yanxin Zhao
Ranch Hand

Joined: May 05, 2004
Posts: 65
Hi:Anton
are you put the Model in suncertify.server? or put Model,view, Controller are all in suncertify.client
mike acre
Ranch Hand

Joined: Sep 23, 2003
Posts: 197
MMmmmmmmm,

Controllers are the least reusable element - Actions and mediation, heavily reliant on implementation.

The View is completely agnostic, just dumb components. Totally resusable and extendable depending on design.

The model is 2-fold:

1. Swing related ComboBoxModel & TableModel etc, okay these could be reused for something else, but they are really specific to Swing.

2. Business Tier, which should be more reusable whether thin or thick client is used. But it so simple.

The spec says 'The IT Director does not envisage much reuse of the first java tech system...' Or mine does anyway.

I don't see a problem with implementing MVC over-and-above Swings in built.
It can be very simple, there is very little function anyway and most of the notification from model is in built.
A simple controller that defines the actions and hooks them into the view with helpers in the view. Initial business setup during controller instantiation and obtaining local or remote connection.
Mutable TableModel & ComboBoxModel that the controller updates.
And a dumb view.


SCJP 1.4, SCJD
Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
Originally posted by Yanxin Zhao:
Hi:Anton
are you put the Model in suncertify.server? or put Model,view, Controller are all in suncertify.client


I put all MVC classes into the client. I put all business logic into the db and remote packages. I am going to do a very basic gui for the server as well, and that class is in server.

Should be about 15 to 20 classes max, and maybe even as low as 10-15. By the way, their website says assignments with roughly 3,500 lines of code can pass. This sounds like they want a spaceship docking program implemented here. I think one thousand lines will be plenty. I'll post the final stats for my project as soon as I am done.
Yanxin Zhao
Ranch Hand

Joined: May 05, 2004
Posts: 65
Hi: Anton
Why not put Model into server side? I want to put Model into Server side. when every View starts, registering a instance into Model. When the data got change, the Model will call every View to refresh. but if you do as what you said, how to implement what I said.
Klaas van Gelder
Ranch Hand

Joined: Jul 08, 2004
Posts: 100
OK guys, thanx for all this info ! It does't, however, really answer my questions....
I would like to get some feedback on my considerations in making the Model and Controller independent of the Swing gui, thus making it impossible to use Action classes in the controller. Pleeze see my first mail for the details... I hope for some well-thought reactions, because this item still gives me sleepless nights...

Greetz, Klaas
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Hi folks,

I don't want to get into specifics so let me try and clarify this issue in a general way.

In an MVC2 architecture the dependencies between the components are cyclical. That is, the View depends on the Model for its data; the Controller depends on the View for its actions; and the Model depends on the Controller to update it. Swing combines the View and Controller into an UI Delegate which cements the dependency between View and Controller by making it bi-directional (i.e. they both depend on each other).

The Model is read by the View and updated by the Controller; however, the client and server representations of the Model do not need to be (and arguably should not be) the same. In this instance, on the client side you should use a subclass of AbstractTableModel. On the server side you should use a representation more closely suited to the physical representation of the data (e.g. the file format). You can then add any necessary methods to your TableModel implementation to convert between the two data representations. If you're lucky enough that the server representation exactly matches that required for the TableModel then great, but you should still make the two logically separate.

I hope this helps,

Regards

Jules
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391

So my question is, can we assume that only Swing clients are used for the application, or should we make the Controller and Model classes completly swing-independent ? If we do, we can still use the swing Action classes, but these would be part of the View instead of the Controller.

Hi Klaus,

The solution by Eugene (John Smith) on March 11, 2003 7:29 AM might address your questions.

http://www.coderanch.com/t/183051/java-developer-SCJD/certification/Confused-MVC
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI design and future extensions...