Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 70824 invoked from network); 26 Jan 2005 03:53:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 26 Jan 2005 03:53:57 -0000 Received: (qmail 78498 invoked by uid 500); 26 Jan 2005 03:53:44 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 78482 invoked by uid 500); 26 Jan 2005 03:53:44 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 78469 invoked by uid 99); 26 Jan 2005 03:53:44 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of eabush@gmail.com designates 64.233.184.194 as permitted sender) Received: from wproxy.gmail.com (HELO wproxy.gmail.com) (64.233.184.194) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 25 Jan 2005 19:53:42 -0800 Received: by wproxy.gmail.com with SMTP id 36so2216wra for ; Tue, 25 Jan 2005 19:53:37 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=Ux5ohSq3isQp7k8Sx45igsUM3xI6CcXMReW6AfyxyuPKTDjt2PVu/N/wH8ozL0pqLEjxg6VgYnit6oXzaxg5DRd/p42/G5D3tjWH2NuDrtQSizDPFZtqRDSgKzC86wgSSlqW2+5AtvrPlsJYDqs1PS5S9EVoUfTx324s4sTQUZk= Received: by 10.54.28.38 with SMTP id b38mr3521wrb; Tue, 25 Jan 2005 19:53:37 -0800 (PST) Received: by 10.54.3.4 with HTTP; Tue, 25 Jan 2005 19:53:37 -0800 (PST) Message-ID: <2e65897505012519531fe42d43@mail.gmail.com> Date: Tue, 25 Jan 2005 21:53:37 -0600 From: Eddie Bush Reply-To: Eddie Bush To: Struts Users Mailing List Subject: Re: [OT] a design question In-Reply-To: <20050125215709.37406.qmail@web41412.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20050125215709.37406.qmail@web41412.mail.yahoo.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I tend to follow the JavaBeans conventions: public class GetData { private String param1; private String param2; public GetData() { } public GetData(String param1, String param2) { setParam1(param1); setParam2(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, Eddie 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: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org