Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Design Patterns Date: Tue, 05 Feb 2013 13:20:03 -0500 Organization: A noiseless patient Spider Lines: 28 Message-ID: References: <3c0d69c3-591d-4d99-8c13-30a0fd1684b3@googlegroups.com> <68pyk4ua9x9m.1nm4lckdwgp86.dlg@40tude.net> <51106eff$0$293$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 5 Feb 2013 18:19:42 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="0d73d8cc209bff1c6395088b400d0605"; logging-data="26140"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BEFD19KPAMbO8LqPrnuFN" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 In-Reply-To: Cancel-Lock: sha1:vKnleFrmb4yynvy1/g9XMqHWeUw= Xref: csiph.com comp.lang.java.programmer:22119 On 2/5/2013 12:51 PM, Stefan Ram wrote: > Eric Sosman writes: >>> Maybe someone can come up with an SCSE where a singleton is needed. >> Runtime.getRuntime().exit(0); > > The library (Java SE) could have been defined to allow: > > class Main > { public static void main( final java.lang.Runtime runtime ) > { runtime.println( runtime.getArgc() + " command-line arguments." ); > runtime.exit(); }} > > or - with less changes to the current state of Java - to allow: > > Runtime.exit( 0 ); A singleton class can be transformed into an uninstantiable class having only static methods. An uninstantiable class with only static methods can be transformed into a singleton class. The two designs are duals: Why should one be deprecated and the other preferred? If all-static vs. singleton is the most pressing problem someone faces, he has an easy life indeed! -- Eric Sosman esosman@comcast-dot-net.invalid