IntelliJ Java IDE
The moose likes OO, Patterns, UML and Refactoring and the fly likes how to identify the pattern ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Reply Bookmark "how to identify the pattern ?" Watch "how to identify the pattern ?" New topic
Author

how to identify the pattern ?

baiju
Greenhorn

Joined: Jun 13, 2001
Posts: 17
hi i am doining the developer exam from sun..
i just posted this query to developer group too.
i thought why not i ask design gurus too..
i am confused which pattern i describe this as...
I know Swings are implemented as MVC.could some one tell me what pattern is my GUI.i thought its reactor patter.
for checkbox i use comboboxmodel and for tables i use absrtract table model..
i use simple structer for GUI like..please look into a snippet of my GUI structure..

code:
--------------------------------------------------------------------------------
public class ClientGui extends JFrame {
Flight Origin = new Flight(origin1[i]);
destination.addElement(Destination);
}
class Flight {
protected String m_name;
public Flight(String name)
{
}
public String getName()
{
}
public String toString()
{
}
}
public FlightPanel(Vector origin, Vector destination)
{ }
public void actionPerformed(ActionEvent e)
{ //call table; ResultTable (result)
}
}
--------------------------------------------------------------------------------
Table GUI........................

code:
--------------------------------------------------------------------------------
public class ResultTable extends JFrame implements ActionListener
{
}
class ResultTableData extends AbstractTableModel
{ }
--------------------------------------------------------------------------------
This is whole structure of my GUI..so what do i call this as.which patter is it? reactor or delegator patter.
or i say MVC pattern....
please comment on it.any help will be appreciated..
baiju
Greenhorn

Joined: Jun 13, 2001
Posts: 17
Why no one wanna answer this..
is developer group people are not allowed here..
i just need help..
baiju
Junilu Lacar
Ranch Hand

Joined: Feb 26, 2001
Posts: 3008
Baiju,
This forum has very limited participation and as such, everybody and anybody who cares to post here are welcome. But because there are relatively few active participants here, don't expect answers right away, if at all.
It's a little hard to tell from the code you gave whether or not it conforms to a known pattern. But then again, I am not an expert in patterns. That's why I hang out here at lot, hoping to learn more about them.
All I can say is that event listeners and the Java delegation event model (which your code obviously uses) fall under the Observer pattern. But that's just a small part of the puzzle. Since patterns vary in scope and usage, it is entirely possible for several patterns to co-exist in a design. Perhaps if we saw more of your code, we might be able to help you see if there is a pattern in it or not.
Just curious though, does the Developer exam specify that you need to use a known pattern? Will Sun ask you to explain your design in terms of patterns?
BTW, you might want to re-register yourself to conform to the JavaRanch naming policy.

Junilu
[How to Ask Questions] [How to Answer Questions] [MiH]
shailesh sonavadekar
Ranch Hand

Joined: Oct 12, 2000
Posts: 1874
Baiju, Welcome to javaranch.
PROPER NAMES ARE NOW REQUIRED
Please look carefully at official naming policy at javaranch & reregister yourself with proper first & last name. Please adhere to official naming policy & help maintain the decorum of the forum.
Waiting for your posts with proper first & last name. Once you have reregister , please let us know about that & then your previous account will be disabled.
Regards.

Your Friendly Bartender
Shailesh.
baiju rahman
Greenhorn

Joined: Jun 16, 2001
Posts: 7
hi
java developer exam needs a FBN assignment to be completed.
abviously when u make a project/asignment we need to code smart.
to code smart we need to apply design patterns.
I too basicall relized it when i was evaluating the assignment .i did coded but had lot of classes which could have been done more efficiently.
so i applied some patterns to make life easier for all.
but now i could not figute out what design pattern i need to mention like MVC,delegator or reacotr.so i am confused..
here is my sample code.
bascially i have 2 combobox and JTble.
combobox i use Comboboxmodel and i extended the abstracttable mode for Jtable.
class UI{
Flight Origin = new Flight(origin1[i]); //i get all vales and call FLIght
origin.addElement(Origin);
}
class Flight
{
protected String m_name;

public Flight(String name)
{
m_name = name;

}
public String getName()
{
return m_name;
}
public String toString()
{
return m_name;
}
}
class FlightPanel extends JPanel implements ActionListener
{

public FlightPanel(String title, Vector origin, Vector destination,ClientGui app)
{
//i populate the combobox with values
}
public void actionPerformed(ActionEvent e)
{
//here i call the table GUI..
}
}

this is how my table look like same as above ....
public class ResultTable extends JFrame implements ActionListener
{}
class ResultTableData extends AbstractTableModel
{
}
this is how my GUI is..
please do add comments...
baiju
ram fbn
Greenhorn

Joined: Jun 15, 2001
Posts: 4
no one for help..
baiju rahmna
Junilu Lacar
Ranch Hand

Joined: Feb 26, 2001
Posts: 3008
Originally posted by baiju rahman:
> to code smart we need to apply design patterns.
> so i applied some patterns to make life easier for all.
baiju,
To code smart, you need to adhere to OO design principles and apply good programming practices. You will find that design patterns are based on basic OO design principles.
Look around this website: http://www.objectmentor.com for articles about good OO design principles and apply them. Read books like "Elements of Java Style", "Effective Java", "Practical Java", "Java Pitfalls" and books on Java programming idioms and apply the advice in those books.
Also, how could you apply patterns without knowing beforehand what they were?
baiju rahman
Greenhorn

Joined: Jun 16, 2001
Posts: 7
yeah
In sense u r correct.my problem was at the end i created lot of unnecessary classes.which could have done much easier
if i would have used design pattern.
at the end i did relize it.i had to just apply it ..
but if i would have thought of design patern life would have been much easier..
still in GUI i could not figure it out.i some times feel its obderver,my events are reactor patter ,i know its MVC but still
i am just confused

baiju
 
 
subject: how to identify the pattern ?
 
Threads others viewed
Command pattern & GUI structure
Are my assumptions reasonable
design pattern
Can't find constructor!
How to construct 'String criteria' ? Help!!!
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com