Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #22110
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.tele2net.at!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail |
|---|---|
| NNTP-Posting-Date | Tue, 05 Feb 2013 03:43:36 -0600 |
| Date | Tue, 05 Feb 2013 09:43:33 +0000 |
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
| Organization | Trollbusters 3 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Design Patterns |
| References | <3c0d69c3-591d-4d99-8c13-30a0fd1684b3@googlegroups.com> <68pyk4ua9x9m.1nm4lckdwgp86.dlg@40tude.net> <singleton-20130204174059@ram.dialup.fu-berlin.de> <51106eff$0$293$14726298@news.sunsite.dk> <singleton-20130205050434@ram.dialup.fu-berlin.de> <1g6plnhx9njxt$.bx5mrpbwc6mi$.dlg@40tude.net> |
| In-Reply-To | <1g6plnhx9njxt$.bx5mrpbwc6mi$.dlg@40tude.net> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Message-ID | <m4qdnYiC9pPVSY3MnZ2dnUVZ8jSdnZ2d@bt.com> (permalink) |
| Lines | 70 |
| X-Usenet-Provider | http://www.giganews.com |
| X-AuthenticatedUsername | NoAuthUser |
| X-Trace | sv3-GjwqobgKHp/e8xRdvx/DI4z2Qju9a/G+29LJKhzIGt4wFxRGYogzX+lLpNA5scEU2iBuVMQJxsu4dC3!0gXEdqyfpwZyBK50/24iGYmzi5Kcx8qS4tvwcKSZWKqxkAjumv4kzuIWp4z2EFOEPGPeBlq1GRM= |
| X-Complaints-To | abuse@btinternet.com |
| X-DMCA-Complaints-To | abuse@btinternet.com |
| X-Abuse-and-DMCA-Info | Please be sure to forward a copy of ALL headers |
| X-Abuse-and-DMCA-Info | Otherwise we will be unable to process your complaint properly |
| X-Postfilter | 1.3.40 |
| X-Original-Bytes | 3815 |
| Xref | csiph.com comp.lang.java.programmer:22110 |
Show key headers only | View raw
On 05/02/13 05:03, Peter Duniho wrote:
> On 5 Feb 2013 04:10:11 GMT, Stefan Ram wrote:
>
>> Arne Vajhøj<arne@vajhoej.dk> writes:
>>>> Pattern or anti-pattern, I never encountered a situation where I felt a
>>>> need for »singletons«.
>>> Other have.
>>
>> Maybe someone can come up with an SCSE where a singleton is needed.
>
> _Needed_ is situation-specific, but examples generally will include
> situations where multiple callers require access to some shared resource
> abstracted by the singleton class. In some cases, a static class suffices.
> But in other cases it's either useful or required to have a singleton (e.g.
> because you need the singleton to implement an interface, something static
> classes in Java can't do).
OK, I know I'm probably still being ignored because I've upset some
people but can someone please explain to me exactly what a 'static
class' is (WRT Java of course)
This is illegal
public static class Foo{...
a class with all static methods certainly can implement an interface
This compiles
public class Foo implements Serializable{
public static void Bar(){
}
}
So what makes a class 'static enough' so that it can't implement an
interface ? (for example)
As for a Singleton
Well some years ago I went for an interview
The interviewer showed me the following line of code(or something like it)
private final Integer var = 10;
He asked me what I thought of it.
I said it was a flag to future maintainers that this value was important
and should not be changed without fully understanding the implications.
I got the job (after lots more questions of course)
And this is one reason I think I might use a singleton
In a system with potentially many statics a Singleton (hopefully) stands
out. It makes explicit the intentions of the developer.
People who understand design patterns will understand what a Singleton
is, if you like it's a form of documentation.
As for an example (I think this has been mentioned before).
I seem to remember back in the day writing a database connection pool
manager as a Singleton. Why ? well it probably seemed like a good idea
at the time :-)
just my 2 euros worth
lipska
--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Design Patterns dougmmika@gmail.com - 2013-02-02 16:17 -0800
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-02 19:39 -0500
Re: Design Patterns Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-02-03 18:52 +0100
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-03 14:23 -0800
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 23:57 -0500
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-09 11:10 -0800
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-09 19:36 -0500
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-09 23:44 -0800
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-09 23:47 -0800
Re: Design Patterns "John B. Matthews" <nospam@nospam.invalid> - 2013-02-10 12:28 -0500
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-10 13:35 -0500
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-10 13:36 -0500
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-10 23:12 -0800
Re: Design Patterns "John B. Matthews" <nospam@nospam.invalid> - 2013-02-09 19:45 -0500
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-02 20:17 -0500
Re: Design Patterns Doug Mika <dougmmika@gmail.com> - 2013-02-02 19:43 -0800
Re: Design Patterns markspace <markspace@nospam.nospam> - 2013-02-02 20:54 -0800
Re: Design Patterns Doug Mika <dougmmika@gmail.com> - 2013-02-02 21:11 -0800
Re: Design Patterns markspace <markspace@nospam.nospam> - 2013-02-03 08:24 -0800
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 23:41 -0500
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-02 21:57 -0800
Re: Design Patterns Roedy Green <see_website@mindprod.com.invalid> - 2013-02-03 06:38 -0800
Re: Design Patterns Joerg Meier <joergmmeier@arcor.de> - 2013-02-04 17:06 +0100
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-04 12:38 -0800
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-04 21:31 -0500
Re: Design Patterns Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2013-02-04 21:03 -0800
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-04 21:25 -0800
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-05 19:54 -0500
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-05 17:51 -0800
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-05 20:54 -0500
Re: Design Patterns lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-05 09:43 +0000
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-05 13:03 -0800
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-05 20:09 -0500
Re: Design Patterns markspace <markspace@nospam.nospam> - 2013-02-05 13:56 -0800
Re: Design Patterns markspace <markspace@nospam.nospam> - 2013-02-05 14:30 -0800
Re: Design Patterns Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2013-02-05 14:33 -0800
Re: Design Patterns lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-06 09:03 +0000
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-05 20:07 -0500
Re: Design Patterns Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-02-05 09:10 -0500
Re: Design Patterns Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-02-05 13:20 -0500
Re: Design Patterns Lew <lewbloch@gmail.com> - 2013-02-05 13:10 -0800
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-05 20:11 -0500
Re: Design Patterns Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-02-05 09:53 -0800
Re: Design Patterns Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-05 20:17 -0400
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-05 19:50 -0500
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-05 20:34 -0500
Re: Design Patterns Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-02-06 08:40 -0800
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 23:38 -0500
Re: Design Patterns Arne Vajhøj <arne@vajhoej.dk> - 2013-02-04 21:41 -0500
csiph-web