Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Changing accessor on public static class Date: Thu, 8 Sep 2016 10:09:27 -0400 Organization: A noiseless patient Spider Lines: 33 Message-ID: References: <734645c0-69c9-4ee2-a9c2-191b9f3710ab@googlegroups.com> <6d2c31d9-1701-404e-b76d-1d1c6510a411@googlegroups.com> <36119403-c21d-422d-8d4b-a3378e27f354@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 8 Sep 2016 14:09:30 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="22e5ab429c5a4bb738666b9c52e40d69"; logging-data="17275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AeWd3NIaPbJOSaPTd2Jby" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 In-Reply-To: <36119403-c21d-422d-8d4b-a3378e27f354@googlegroups.com> Cancel-Lock: sha1:uN+EQrIaYS5uwnrG8G931GAnRSk= Xref: csiph.com comp.lang.java.programmer:35570 On 9/8/2016 9:35 AM, Eric Douglas wrote: > On Thursday, September 8, 2016 at 8:38:33 AM UTC-4, Eric Sosman wrote: >> Do you have a copy of "Effective Java" by Joshua Bloch? If not, >> I strongly recommend you get one; it's an excellent work that I think >> will improve just about anyone's Java. >> >> When you get the book, read "Item 18: Favor static member classes >> over nonstatic" for Bloch's take on the pros and cons of static nested >> classes vs. inner classes. > > I don't have a copy but I searched and found it online. > https://github.com/HackathonHackers/programming-ebooks/blob/master/Java/Effective%20Java%20(2nd%20Edition).pdf > > This was actually item 22, and I'm not sure the use case for static applies to any of my inner classes. I believe all inner classes I've written are private classes and normally if not always require references to variables and/or methods of the outer class. In my copy, Item 22 is "Replace function pointers with classes and interfaces." (Perhaps you found an edition newer than my venerable 2004 "7th printing.") I still recommend obtaining the book; it's a good 'un. In any event, it is of course possible that your patterns of use for nested classes are unlike those Bloch knows about -- and if they are, Bloch's reasons for preferring the simplicity of static classes don't apply. Whether the O.P.'s classes (Whatever became of the O.P., anyhow? Did he lose interest in his own question?) are more like yours or more like Bloch's remains unknown. One final nitpick and niggle: An "inner class" is by definition not static, so "not sure the use case for static applies to any of my inner classes" is a tautology. -- esosman@comcast-dot-net.invalid The Tooth Fairy has gone high-tech, now pays in Bitecoin.