Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Similar GUI's

 
Ranch Hand
Posts: 489
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Fernando Franzini
Ranch Hand
Posts: 489
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Fernando Franzini
Ranch Hand
Posts: 489
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel
Great ideia !!
Thanks.
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic