Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.42!gegeweb.eu!nntpfeed.proxad.net!feeder2-2.proxad.net!proxad.net!feeder1-2.proxad.net!74.125.46.80.MISMATCH!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: state design pattern: question: inner or outer class: which is better? Date: Wed, 30 Nov 2011 14:28:56 -0800 (PST) Organization: http://groups.google.com Lines: 28 Message-ID: <1854299.24.1322692136633.JavaMail.geo-discussion-forums@preu18> References: <4cb57cb9-f87c-4409-9e35-184bdc661f48@l24g2000yqm.googlegroups.com> <4652620.1006.1322680967944.JavaMail.geo-discussion-forums@prfi36> <40add71o90o9p31s9mo3sj468vaj12cb1k@4ax.com> Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 2620:0:1000:fd2b:224:d7ff:fe69:5838 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1322692549 13667 127.0.0.1 (30 Nov 2011 22:35:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 30 Nov 2011 22:35:49 +0000 (UTC) In-Reply-To: <40add71o90o9p31s9mo3sj468vaj12cb1k@4ax.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2620:0:1000:fd2b:224:d7ff:fe69:5838; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10384 Gene Wirchenko wrote: > Lew wrote: > [snip] >=20 >> As with non-inner nested classes, if the type is needed by any other cla= ss >> and its semantics are not tightly bound to those of the proposed >> outer class, a standalone class is probably more appropriate. >> >> If the semantics are tightly bound to the proposed outer class, and the = sprite=20 > state does not depend on the outer class instance's state, then a > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > I do not follow this. Please explain. >=20 > nested class might be appropriate. If an instance of the prospective nested class does not use any of the inst= ance state of the prospective outer class, then it should not be an inner c= lass, but it might be a candidate for a nested class. If it does depend on the state of the outer-class instance, for example if = it references an instance variable of the outer-class instance, then it wil= l have to be an inner class. This follows directly from the inability of a= static member to access an instance member. --=20 Lew