aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Similar GUI's 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 "Similar GUI Watch "Similar GUI New topic
Author

Similar GUI's

Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 486
    
    2

Hi Folks

I've observing.....and my assignment have 3 GUI's very similar - local client, remote client and server starter . I mean....all of then have one central panel with input datas and one south painel with 2 buttons...local client and remote client have "connect" and "exit" buttons....server stater have "start" and "exit" buttons.
Wich is the best approach to solve this implementation ?
1. Duplicate all code inside all classes ?
2. Use an inteligent config painel with MVC like Dennis's DVD that in runtime display apropriated widgets ?
3. Use inheritance, centralizing the duplicate code in some super-class ?
4. There are anothers approach ?
What do you ranches have used or thought about ?
Regards.


Fernando Franzini - Java Blog
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334

Hi Folks

I've observing.....and my assignment have 3 GUI's very similar - local client, remote client and server starter . I mean....all of then have one central panel with input datas and one south painel with 2 buttons...local client and remote client have "connect" and "exit" buttons....server stater have "start" and "exit" buttons.
Wich is the best approach to solve this implementation ?
1. Duplicate all code inside all classes ?
2. Use an inteligent config painel with MVC like Dennis's DVD that in runtime display apropriated widgets ?
3. Use inheritance, centralizing the duplicate code in some super-class ?
4. There are anothers approach ?
What do you ranches have used or thought about ?
Regards.

Hi,

I think it is also a design decision. I have used separate class for each mode. For example, local mode UI consists of view, model and controller. Similarly 3 classes for network client and server. In this design, code might be duplicated across other classes but it seems to be an elegant design. If there is a modification in any one of the modes, the modification will not impact other modes. It will eliminate the possibility of producing new bugs during maintenance



I am also eagerly waiting for some others response

sat
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

Howdy, Fernando!

1. Duplicate all code inside all classes ?


Champion, this is never a good approach. All code that is common to two classes must be abstracted to a super class.
You know... this may be a good situation for you to use the Template Method pattern. You can have your template method return your panel, and in your super class, it will be just an abstract method. So you have a method in your abstract super class that builds everything and calls an abstract method. Then, for each class that builds each particular window, you override the abstract method so it behaves as you need!


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 486
    
    2

Fala mestre Roberto !!!
Hello master Roberto lolll
That was exactly what I've tought...centralizate one abstract super and use Template Method offering freedom for each GUI implements its specific owner function.
Thanks
Somebody else have another sugestion or ideia ?
Regards.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5535
    
  13

Hi Fernando,

A totally other idea (and what I've done): use just 2 windows, one as the server application (input possibility for configuration settings and a start/stop button) and one as the main application window (the client, used in both remote mode and local mode). Because there is no difference in functionality between a remote client and a local client, so why use 2 seperate GUIs. The only thing that has to change is the input possibility for configuration settings. And that's easy to solve with a dialog.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 486
    
    2

Hi Roel
Great ideia !!
Thanks.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

Well, from what I had understood, this is when you start the application; you need different fields for the 3 modes the application can be started, so this is when the application is being started...
Bob Wheeler
Ranch Hand

Joined: Apr 24, 2009
Posts: 317
Hi,

I sort of followed Sats approach.
I have two different classes for configuration the application in client and stand alone mode (The serve mode follows a different algorithm). I decided that even if the configuration class has almost the same method headers (I could define a configuration Interface), the content of the methods is quite different. They have different fields, Roberto said already, so they do different text validation, they need to access different property pairs. No method is reused.
I think that explains the use of different classes for the assessor, I hope.

cheers
Bob


SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Similar GUI's