Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #38927
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2019-04-17 14:05 -0700 |
| References | (4 earlier) <q8tod9$kb9$1@gioia.aioe.org> <7ivllvz2ukra$.qlcrlm81adao.dlg@40tude.net> <q95ev0$3s8$1@dont-email.me> <28f31a7a-5bdf-4eaa-ad70-df6c0751b5ff@googlegroups.com> <q97v7m$mr6$1@dont-email.me> |
| Message-ID | <8d955e2b-8532-4591-9868-c86aa1913d01@googlegroups.com> (permalink) |
| Subject | Re: Java variable access |
| From | Eric Douglas <e.d.programmer@gmail.com> |
On Wednesday, April 17, 2019 at 3:36:33 PM UTC-4, Daniele Futtorovic wrote: > > If you leave off the validation and just declare class variable public double unitPrice, you either validate it where it gets used or never validate assuming it's ok to just throw an error where it would be used if it somehow gets an invalid value. > > That has to be the worst advice I've read in quite a while. > > -- > DF. I would agree that's probably not a good idea, but I'm sure I've seen it done.. Personally I think option 2 sounds better.. preferably use an IDE or plugin that can create getters and setters for you and do the validating for you if there are multiple fields with the same validation requirement. If not then just build in a framework for it, try to prevent duplicating code as much as possible.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | 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