🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7704

Re: Singleton Pattern: Use All Static Methods or Private Constructor?

#7704
From: John McGrath TeamB
Date: Tue, 29 May 2001 01:38
29 lines
1801 bytes
On Mon, 28 May 2001 11:56:03 -0500, "Jack Frosch" <jackfrosch[NO SPAM]
@mail.com> wrote:

> Approach #2 clearly meets the pattern description of the GoF,
> but I'm wondering if there are any uniquely-Java reasons why
> approach #1 might be preferable?

I can think of two possible advantages to approach #1:

1) The brevity of the syntax:
    #1:  MyClass.method();
    #2:  MyClass.getInstance().method();

2) It is slightly more efficient, since it requires an object 
reference.

I tend to use approach #2 if it makes sense to me to think of the
thing as an object, which is usually the case.  I will *always* use
this approach if it is in any way logically consistent to have more
than one instance of that object.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <MPG.157cc4f2505659cc98a23b@forums.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!feeds.vnews.net!nntp.cifnet.net!feed2.onemain.com!feed1.onemain.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3b128359$1_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,604521ee4b628609
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-05-28 19:30:03 PST
From: John McGrath  [TeamB] <ng-b@JPMcGrath.net>
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: Singleton Pattern: Use All Static Methods or Private Constructor?
Date: Mon, 28 May 2001 21:38:02 -0400
Message-ID: <MPG.157cc4f2505659cc98a23b@forums.borland.com>
References: <3b128359$1_1@dnews>
X-Newsreader: MicroPlanet Gravity v2.30
NNTP-Posting-Host: 209.92.40.60
X-Trace: dnews 991100281 209.92.40.60 (28 May 2001 18:38:01 -0700)
Lines: 29
X-Authenticated-User: jpmcgrath
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!feeds.vnews.net!nntp.cifnet.net!feed2.onemain.com!feed1.onemain.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!dnews