Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: Changing accessor on public static class Date: Thu, 8 Sep 2016 19:30:35 -0400 Organization: Aioe.org NNTP Server Lines: 49 Message-ID: References: <734645c0-69c9-4ee2-a9c2-191b9f3710ab@googlegroups.com> <6d2c31d9-1701-404e-b76d-1d1c6510a411@googlegroups.com> NNTP-Posting-Host: 7SK6yTFfqwlIPNBLl3l7Qg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:35576 On 9/8/2016 7:54 AM, Eric Douglas wrote: > On Wednesday, September 7, 2016 at 6:52:53 PM UTC-4, Arne Vajhøj wrote: >> So your decision logic should be: >> >> if I want to put class declaration within another class then >> if the class really need to refer directly to members of the enclosing instance then >> use inner class >> else >> use static nested class >> end if >> else >> use a normal class >> end if > > I'm not sure what you're saying. I have plenty of inner classes but > I've only ever made them static when there's a need to instantiate > them from a static method or static block. I am saying that you should do different. Not: only if I need to use from static method use static But: only if I need direct access to enclosing instances data use non-static I am saying that you should change your default. Java chose a slightly misleading syntax. actual syntax: public static class Foobar better syntax: public class Foobar because: - it is really just a normal class with an unusual name - that is the syntax for the same semantics in C++ and C# actual syntax: public class Foobar better syntax: public verycompleximplicitrelationship class Foobar because: - that is what it is - it would discourage accidental usage Arne