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


Groups > comp.lang.java.help > #861

Re: Hungarian Notation and Java

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!k23g2000pri.googlegroups.com!not-for-mail
From lewbloch <lewbloch@gmail.com>
Newsgroups comp.lang.java.help
Subject Re: Hungarian Notation and Java
Date Wed, 13 Jul 2011 08:47:45 -0700 (PDT)
Organization http://groups.google.com
Lines 63
Message-ID <1e5efca0-bba1-4a71-9ea6-15399b85e767@k23g2000pri.googlegroups.com> (permalink)
References <b4d806bc-4f94-4655-8699-5e1c32e111ed@q1g2000vbj.googlegroups.com>
NNTP-Posting-Host 172.19.13.20
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Trace posting.google.com 1310573824 30620 127.0.0.1 (13 Jul 2011 16:17:04 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Wed, 13 Jul 2011 16:17:04 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info k23g2000pri.googlegroups.com; posting-host=172.19.13.20; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-Header-Order ASELCHRU
X-HTTP-UserAgent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1,gzip(gfe)
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.help:861

Show key headers only | View raw


Steve wrote:
> Is there any reason left to use Hungarian notation with Java?
>

"left"?  There never was any reason (other than emotional) to use
Hungarian notation with any language, much less Java.  The Java naming
conventions, published in 1999, make no mention of it.
<http://www.oracle.com/technetwork/java/codeconv-138413.html>

So where do you get "left"?

> Many free IDEs have code completion, so anyone can click on a variable
> and get a list of available functions, so there is less of a need to
> know the datatype.    Also, with polymorphism many Java objects will
> not have a "single" datatype, so a hungarian [sic] notation will not be
> completely accurate.
>

Not correct.  An object has a single type - its own type - always.
Alternatively, you can say that every object not itself of type
'Object' has many types, i.e., all those of which its leaf type is a
subtype.

Regardless, Hungarian notation never was "completely accurate" at
indicating type.  Furthermore, it's only a commenting standard.  Have
you never seen code where the comments and the code itself diverged
over time?  Java has a compiler-enforced type system.

> Am I missing some advantage of Hungarian notation that would still
> make it worthwhile using with Java?
>

Why do you even bother asking this question?

> Is there an emerging naming convention in Java to do what Hungarian
> notation did......put something in the variable name, in a standard
> way, that gives you a clue as to what the variable is?

There is the standard Java coding conventions, modified by house
standards for any given project.

These standards have been in play for quite a while, nearly as long as
Java has been popular.

The point of the naming conventions is to indicate not what a variable
"is", whatever the heck you mean by that, but what its domain purpose
is.  For example, a variable to hold the total number of widgets at
some point in an algorithm might be called 'totalNumberOfWidgets', or
more tersely, 'widgetTotal'.  Whether the type is 'double' or 'Double'
or 'BigInteger' is not needed in the name, because the freaking
declaration (say, 'BigInteger widgetTotal;') completely expresses
that.

Forget about Hungarian notation and use the well-documented and
universally-known coding standards about which no one can be ignorant
and still lay claim to being a Java programmer.

(There are some minor variations in practice that many people accept.
That's an Editor Wars debate for another thread.)

--
Lew

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


Thread

Hungarian Notation and Java Steve <tinker123@gmail.com> - 2011-07-13 07:46 -0700
  Re: Hungarian Notation and Java lewbloch <lewbloch@gmail.com> - 2011-07-13 08:47 -0700
  Re: Hungarian Notation and Java markspace <-@.> - 2011-07-13 09:23 -0700
  Re: Hungarian Notation and Java Roedy Green <see_website@mindprod.com.invalid> - 2011-07-13 15:33 -0700
  Re: Hungarian Notation and Java Lothar Kimmeringer <news200709@kimmeringer.de> - 2011-07-14 18:45 +0200
    Re: Hungarian Notation and Java lewbloch <lewbloch@gmail.com> - 2011-07-14 17:30 -0700
  Re: Hungarian Notation and Java Travers Naran <tnaran@gmail.com> - 2011-07-17 22:06 -0700

csiph-web