File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes what design Pattern to use for this problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "what design Pattern to use for this problem" Watch "what design Pattern to use for this problem" New topic
Author

what design Pattern to use for this problem

Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

Hi guys,
I'm trying to come up with the best design for the following requirements:
There would be many commands mapped with buttons or menu items. each one of these commands will launch a different GUI window with different functionality.
the UI windows will have many common components but there will be a JTable which need to be different for each command.
each common GUI component in each window X will do a different job. ex: there will be a common button B in all windows. in window X this button will execute a given task TX. but in window Y it will execute a different task TY.
So
command X -> window X (JTable with a Table model X +other UI common components)
command Y -> window Y (JTable with a Table model Y +other UI common components)
and so on...
this system must be extensible so that every time i add a new command, i'll only need to implement a new Window for this command.

what is the best design patterns and architectural designs to implement such system?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Command pattern?
Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

David Newton wrote:Command pattern?

and the Jtables ? use Factory pattern?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Yahya Elyasse wrote:
David Newton wrote:Command pattern?

and the Jtables ? use Factory pattern?


What's the design problem that the Factory pattern would solve here?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
You can apply Abstract Factory to create "families" of product.

For example, you can do something like the following:


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Sanjay Singhaniya
Greenhorn

Joined: Feb 21, 2009
Posts: 25
You can use state design pattern to capture which button is clicked.
button X implies State X
button Y implies State Y
If many of GUI components remain the same, you can use state design pattern. State design pattern will capture what changes and you can implement common components only once. Common components will delegate the call to State object to implement state-specific functionality.
I would like to have inputs over my design.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: what design Pattern to use for this problem