struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eddie Bush <>
Subject Re: [OT] a design question
Date Wed, 26 Jan 2005 03:53:37 GMT
I tend to follow the JavaBeans conventions:

public class GetData {
  private String param1;
  private String param2;

  public GetData() {

  public GetData(String param1, String param2) {

  public String getParam1() {
    return param1;

  public void setParam1(String param1) {
    this.param1 = param1;

  public String getParam2() {
    return param2;

  public void setParam2(String param2) {
    this.param2 = param2;

Note that the singleton pattern has nothing to do with the way you
pass parameters.  An object being a singleton means that there may
never be more than one object of that type, and that you're guaranteed
there never will be more than one object of that type.  See GoF.

Note that, to follow JavaBean conventions, if you specify a
constructor that has parameters, you'll have to also specify one that
does not.  The no-args constructor allows the class to be dynamically
instantiated.  Following the JavaBean convention for properties, each
property should have its own get/set method.

I personally like this approach better because I can create them
dynamically and set their properties dynamically.  I get a lot of
milage out of beans by doing this.

I didn't really see a question?  Is your question how to best write
the class?  Well, you've got my 2 cents.

Good Luck,


On Tue, 25 Jan 2005 13:57:09 -0800 (PST), Ashish Kulkarni
<> wrote:
> Hi
> Suppose i have a class, which required 3 parameters to
> do some process, out of 3 parameters 2 are standard
> and only one changes depending upon the process.
> I dont want to hard code those 2 values since these
> can be change (this is not a web application so i
> cannot use session)
> What i want to do is create one instance of this class
> with the constant parameters setup,
> So a sort of Singleton pattern,
> This class will have no knowledge to read those 2
> parameters, and have to be supplied by some other
> class
> How will be design this class,
> my class example
> public class GetData
> {
>  private String parm1, parm2;
>  public GetData(String parm1, String parm2)
>   {
>     this.parm1 = parm1;
>     this.parm2 = parm2;
>   }
>  public void doSomeThing(String parm3)
>   {
>        // do some logic here
>   }
> }
> ashish

Eddie Bush

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message