Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #38900
| X-Received | by 2002:ac8:2b82:: with SMTP id m2mr7778740qtm.11.1555077448062; Fri, 12 Apr 2019 06:57:28 -0700 (PDT) |
|---|---|
| X-Received | by 2002:a25:4c81:: with SMTP id z123mr46884484yba.277.1555077447850; Fri, 12 Apr 2019 06:57:27 -0700 (PDT) |
| Path | csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!t9no1497194qtn.0!news-out.google.com!i8ni706qtr.1!nntp.google.com!t9no1497186qtn.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.java.programmer |
| Date | Fri, 12 Apr 2019 06:57:27 -0700 (PDT) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=50.78.95.177; posting-account=2czF5goAAAD4GBMPIGV4KcD2K4PhoB_H |
| NNTP-Posting-Host | 50.78.95.177 |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <109a7224-f392-46c3-bf56-7d8bf2bfb4bf@googlegroups.com> (permalink) |
| Subject | Java variable access |
| From | Eric Douglas <e.d.programmer@gmail.com> |
| Injection-Date | Fri, 12 Apr 2019 13:57:28 +0000 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | quoted-printable |
| Lines | 9 |
| Xref | csiph.com comp.lang.java.programmer:38900 |
Show key headers only | View raw
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. Advantages to making them private would include 1) deprecating the getter/setter if the variable at some point is no longer needed, 2) customizing the getter/setter if you change the class to require special code to execute every time they set a value, and 3) changing the variable name without affecting any code trying to get/set the value.
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Java variable access Eric Douglas <e.d.programmer@gmail.com> - 2019-04-12 06:57 -0700
Re: Java variable access Arne Vajhøj <arne@vajhoej.dk> - 2019-04-12 10:06 -0400
Re: Java variable access Eric Douglas <e.d.programmer@gmail.com> - 2019-04-12 07:23 -0700
Re: Java variable access Arne Vajhøj <arne@vajhoej.dk> - 2019-04-12 10:35 -0400
Re: Java variable access Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-04-12 10:58 -0400
Re: Java variable access Eric Douglas <e.d.programmer@gmail.com> - 2019-04-12 08:31 -0700
Re: Java variable access Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-04-12 14:40 -0400
Re: Java variable access Arne Vajhøj <arne@vajhoej.dk> - 2019-04-12 12:31 -0400
Re: Java variable access Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-04-12 10:56 -0400
Re: Java variable access Joerg Meier <joergmmeier@arcor.de> - 2019-04-12 23:11 +0200
Re: Java variable access Arne Vajhøj <arne@vajhoej.dk> - 2019-04-12 21:51 -0400
Re: Java variable access Joerg Meier <joergmmeier@arcor.de> - 2019-04-13 21:59 +0200
Re: Java variable access Arne Vajhøj <arne@vajhoej.dk> - 2019-04-13 18:38 -0400
Re: Java variable access Joerg Meier <joergmmeier@arcor.de> - 2019-04-16 22:08 +0200
Re: Java variable access Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-04-16 16:46 -0400
Re: Java variable access Joerg Meier <joergmmeier@arcor.de> - 2019-04-16 23:01 +0200
Re: Java variable access Eric Douglas <e.d.programmer@gmail.com> - 2019-04-17 06:42 -0700
Re: Java variable access Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-04-17 21:35 +0200
Re: Java variable access Eric Douglas <e.d.programmer@gmail.com> - 2019-04-17 14:05 -0700
Re: Java variable access Joerg Meier <joergmmeier@arcor.de> - 2019-04-19 10:40 +0200
Re: Java variable access Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-04-19 17:20 -0400
csiph-web