Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38908

Re: Java variable access

X-Received by 2002:a0c:8ae4:: with SMTP id 33mr6856708qvw.26.1555083072130; Fri, 12 Apr 2019 08:31:12 -0700 (PDT)
X-Received by 2002:a81:148c:: with SMTP id 134mr46959856ywu.217.1555083071763; Fri, 12 Apr 2019 08:31:11 -0700 (PDT)
Path csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!t9no1643965qtn.0!news-out.google.com!i8ni730qtr.1!nntp.google.com!t9no1643956qtn.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.java.programmer
Date Fri, 12 Apr 2019 08:31:11 -0700 (PDT)
In-Reply-To <q8q927$4ua$2@dont-email.me>
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
References <109a7224-f392-46c3-bf56-7d8bf2bfb4bf@googlegroups.com> <q8q60r$rcu$1@gioia.aioe.org> <2a9f711b-78f4-483b-a94d-d7bb86434f1f@googlegroups.com> <q8q927$4ua$2@dont-email.me>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <e8937b9d-a0fc-45f2-87b5-6cf00338788d@googlegroups.com> (permalink)
Subject Re: Java variable access
From Eric Douglas <e.d.programmer@gmail.com>
Injection-Date Fri, 12 Apr 2019 15:31:12 +0000
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
Lines 18
Xref csiph.com comp.lang.java.programmer:38908

Show key headers only | View raw


On Friday, April 12, 2019 at 10:58:22 AM UTC-4, Eric Sosman wrote:
> > That was my thought, to stick with all private/protected variables. [...]
>      Note that `protected' variables are accessible *everywhere*
> unless your class cannot be extended at all.
> 

Ah right, protected methods are common (and I keep thinking about the use case where they must be called by a different class in the same package and sometimes forget about possibly anything extending the class), but declaring a variable protected would have the same potential issues as declaring it public unless the class is final (how common is that?).

I expect it makes sense to declare custom object variables always private.  I was thinking more simple objects.  If your variable is a String the worst that happens is something sets it to null?  If your variable is an int, even if it's supposed to be a multiple of 3, if you don't validate it with a setter you could validate it in a method that uses it's value?  If your variable is an enum?

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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