• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

design pattern

 
baiju
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
i used factory pattern in client .but i just could not find what pattern shall i mention for my GUI.
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..

Table GUI........................

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..
[ Inserted CODE tags to make your code more readable. Please take a look here for more information -- PdH ]
[This message has been edited by Peter den Haan (edited June 15, 2001).]
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would think MVC pattern is the best way to describe it. Although patterns give you a powerful language to talk about your code, don't try to give every single line a pattern name
- Peter

[This message has been edited by Peter den Haan (edited June 15, 2001).]
 
baiju
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
Thanks a lot. i was just confused hearning comments fro lot of peoples.so i am satisfied now.
so i can just say that i am using MVC pattern .
yeah could u look at my whole design.i used 2 different classes for local and remote mode..Is it convincing
baiju
 
Marre Mask
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It would be interesting if you could explain how and why you used factory pattern in the client?
 
baiju
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My whole design looks confusing now for me..
hope u can suggest i am correct or not or just i can go with it.
i just dont wanna waste more time on it..
DataServer interface{
//all the public methods of data class
}
.............remote mode.........................
class DataServerImpl extends unicastremoteobject implements DataServer
{
//i do the rmi registry
//implements all the dataclass public methods..
}
..................local mode.......................
class DataClientLocalImpl implements DataServer
{
//d=new Data();
//implements all the dataclass public methods..
}
i use factory to determine local or remote..
public class FactoryModel
{
public DataClient getClass(String mode) throws Exception
{
if(mode.equals("local"))
{
return new DataClientLocalImpl() ;}
else
{
return new DataServerImpl() ;

}
}
}
i have 2 options ..
1st approach.......
i can use the DataServer for both the mode...by just doining
if (local)
d=new data();
else
d=DataServer();
but since if i unicast remote object i need stubs and skeleton in local mode too..
2nd approach(which i am currently using as shown above)
i have implementation for remote and local mode two different classes.but both do the same thing..
Do comment on it..i am in a dilemma now i was planning to be done with this week end..
but i thought may be i need to correct some thing..
do add ur comments..
Kind Regards
 
baiju
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please i will appreciate more comments
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If DataServer has all the public methods of the Data class, and just those - i.e. Data implements DataServer - then where's the need for DataClientLocalImpl? DataServerImpl's stub would implement DataServer and could act as a remote Data replacement.
You may have to split the DataServer interface in two, otherwise Data would be instanceof Remote.
By the way, there are many souls on the 'ranch, sometimes with surprisingly similar names. That's why we prefer folks to register with their full name. Could you please re-register?
- Peter

[This message has been edited by Peter den Haan (edited June 16, 2001).]
 
baiju rahman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did re registered..so complete name is baiju rahman.
I did understand ur explanation.
but if i dont want to implement
dataserver in my data class.
is there any other way..
regards
baiju
 
baiju rahman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Peter den Haan
I did atleast did it..just used the factory pattern.
and i did extend dataserver in data claa.
so works fine..I almost from few days changed
3 to 4 time whole my design.
may be i should have thought of it before coding.
i just started coding and at the end while
writing the design doc .i thought may be there r better way..
thanks
baiju
 
baiju rahman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As rick suggested
public interfact Database
public class DataServer implements Databasepublic
class Data implements Databasepublic
class DataclientImpl implements DataServer
i did elimitate lot of unwanted classes and created a wrapper
using factory pattern i decide the local and remote mode..
but the way we implement the DBInterface in both data and dataserver..is it a adapter pattern
baiju
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic