Path: csiph.com!aioe.org!.POSTED.O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: Java variable access Date: Sat, 13 Apr 2019 18:38:35 -0400 Organization: Aioe.org NNTP Server Lines: 36 Message-ID: References: <109a7224-f392-46c3-bf56-7d8bf2bfb4bf@googlegroups.com> <13t97bxk9km7n$.ooqi8n8ocm7f$.dlg@40tude.net> <13ak6boysjgrh$.1h4x7tkjgs00q$.dlg@40tude.net> NNTP-Posting-Host: O5hsyUvK01te0L/SZurVSQ.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:60.0) Gecko/20100101 Thunderbird/60.6.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: csiph.com comp.lang.java.programmer:38915 On 4/13/2019 3:59 PM, Joerg Meier wrote: > On Fri, 12 Apr 2019 21:51:28 -0400, Arne Vajhøj wrote: > >> On 4/12/2019 5:11 PM, Joerg Meier wrote: >>> On Fri, 12 Apr 2019 06:57:27 -0700 (PDT), Eric Douglas wrote: >>>> If one would need to get and set values of simple class variables, >>>> is it better to declare public variables or declare them private with >>>> getter/setter methods, or are there situations where you would do both? >>>> I have been declaring all variables private though sometimes creating >>>> the getter/setter methods just seems like unnecessary busy work if >>>> making them public would accomplish the same thing. >>> > >>> You are welcome. There is also @Data, which amongst a few other things adds >>> @Getter and @Setter to all your fields. >> But today wouldn't it be better to switch to Kotlin? > > From the TIOBE index, 2019: > > Rank Rank (2018) Language Rating > 1 1 Java 15.035% > [...] > 35 None Kotlin 0.337% > > So, no. Absolutely not. I am not sure that comparison is relevant. We are not discussing Java vs Kotlin. We are discussing Java/Lombok vs Kotlin. The Java way is to write the getters and setters. Arne