Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2052
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: Why "Static field should be accessed in a static way" ? |
| Date | 2012-08-22 08:45 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <k12k9j$k7m$1@dont-email.me> (permalink) |
| References | <5034c6c8$0$282$14726298@news.sunsite.dk> |
On 8/22/2012 7:47 AM, Timothy Madden wrote:
> Hello
>
> To my knowledge, using non-static access even for static fields/methods
> is good practice. It allows for later changing the field into and
> instance field.. It also allows for using that field without knowing
> much wheather it is static or not.
It seems to me that it would be difficult to make effective
use of a field without knowing whether it was instance-specific
or class-specific.
(CAUTION: Weak Analogy Ahead)
In the matter of the State v Madden, the Court ruled
a) The defendant Madden is guilty of making a Gawdawful racket
in the middle of the night, and is fined $100 for disturbing
the peace, or
b) The law against racket-eering (sorry) is an unconstitutional
abridgement of free speech, and is hereby struck from the books.
One of these judgements is relevant to a particular Person instance
(Madden must pay the fine), while the other affects every Person
(nobody will ever have to pay such a fine). It seems to me there's
a fundamental difference, and that the Court would have to be aware
of that difference in issuing a ruling. Similarly, when you use a
field you need to understand whether its value is specific to one
instance or is a common characteristic shared by all. Ask someone
for his name and you expect to hear "Timothy Madden," not "Homo
Sapiens."
The same considerations lead me to doubt that "later changing
the field into an instance field" is something one would be likely
to do. It's certainly possible to remove static fields and introduce
instance fields, but I'd argue that this can't be done blindly or
mechanically.
> Is there some reason why tools like Eclipse claim the field should be
> accessed in a static way ?
Probably because the toolmakers think instance-ish access to
non-instance data is a Java misfeature.
--
Eric Sosman
esosman@ieee-dot-org.invalid
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why "Static field should be accessed in a static way" ? Timothy Madden <terminatorul@gmail.com> - 2012-08-22 14:47 +0300
Re: Why "Static field should be accessed in a static way" ? Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-22 08:45 -0400
Re: Why "Static field should be accessed in a static way" ? Lew <noone@lewscanon.com> - 2012-08-22 06:31 -0700
Re: Why "Static field should be accessed in a static way" ? markspace <-@.> - 2012-08-22 08:54 -0700
Re: Why "Static field should be accessed in a static way" ? Timothy Madden <terminatorul@gmail.com> - 2012-08-22 21:05 +0300
Re: Why "Static field should be accessed in a static way" ? Roedy Green <see_website@mindprod.com.invalid> - 2012-08-23 09:44 -0700
Re: Why "Static field should be accessed in a static way" ? Roedy Green <see_website@mindprod.com.invalid> - 2012-08-23 08:58 -0700
csiph-web