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


Groups > comp.programming > #1911 > unrolled thread

Hungarian notation

Started bybob <bob@coolfone.comze.com>
First post2012-07-06 14:01 -0700
Last post2012-08-08 14:57 -0400
Articles 8 — 8 participants

Back to article view | Back to comp.programming


Contents

  Hungarian notation bob <bob@coolfone.comze.com> - 2012-07-06 14:01 -0700
    Re: Hungarian notation Mensanator <mensanator@aol.com> - 2012-07-06 17:47 -0700
    Re: Hungarian notation "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-07-07 09:33 +0200
    Re: Hungarian notation "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-07-07 10:23 +0100
      Re: Hungarian notation Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-07-07 12:10 -0700
    Re: Hungarian notation BGB <cr88192@hotmail.com> - 2012-07-09 22:13 -0500
    Re: Hungarian notation malcolm.mclean5@btinternet.com - 2012-07-14 13:52 -0700
      Re: Hungarian notation lawrence.jones@siemens.com - 2012-08-08 14:57 -0400

#1911 — Hungarian notation

Frombob <bob@coolfone.comze.com>
Date2012-07-06 14:01 -0700
SubjectHungarian notation
Message-ID<e6de6322-c6e5-4762-ad48-e2183ffbb6a6@googlegroups.com>
What do you all think of Hungarian notation?  Is this worth using?

[toc] | [next] | [standalone]


#1914

FromMensanator <mensanator@aol.com>
Date2012-07-06 17:47 -0700
Message-ID<e1040721-01b9-4a7b-9aab-ff5a1951516d@h9g2000yqi.googlegroups.com>
In reply to#1911
On Jul 6, 4:01 pm, bob <b...@coolfone.comze.com> wrote:
> What do you all think of Hungarian notation?  Is this worth using?


I will not buy this record, it is scratched.

[toc] | [prev] | [next] | [standalone]


#1915

From"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Date2012-07-07 09:33 +0200
Message-ID<1kb5astpjgfa5$.1bgrcc8s3orr9.dlg@40tude.net>
In reply to#1911
On Fri, 6 Jul 2012 14:01:58 -0700 (PDT), bob wrote:

> What do you all think of Hungarian notation?

One of few really stupid ideas. It is difficult to achieve such degree of
perfection in stupidness.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

[toc] | [prev] | [next] | [standalone]


#1917

From"Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Date2012-07-07 10:23 +0100
Message-ID<IuCdnU3t18WSnWXSnZ2dnUVZ8iudnZ2d@bt.com>
In reply to#1911
bob wrote:

> What do you all think of Hungarian notation?  Is this worth using?

Depends whether you are talking about Hungarian notation as it was originally 
intended, for instance see: http://www.joelonsoftware.com/articles/Wrong.html 
for a discussion of the original intent (I'm assuming Joel is correct here -- I 
haven't tried to check).  The wikipedia article (with its distinction between 
the "apps" and "system" flavours of hungarian notation) is also informative.

But it doesn't depend all /that/ much.  My answers are "ugh!" and "no" in both 
cases, albeit for somewhat different reasons.

    -- chris 

[toc] | [prev] | [next] | [standalone]


#1918

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2012-07-07 12:10 -0700
Message-ID<4R%Jr.133$jl.72@newsfe14.iad>
In reply to#1917
On 7/7/12 2:23 AM, Chris Uppal wrote:
> bob wrote:
>
>> What do you all think of Hungarian notation?  Is this worth using?
Honestly, this felt like flame-bait, but it's sparked some interesting 
conversation that doesn't (yet) seem adversarial, so thanks!
>
> Depends whether you are talking about Hungarian notation as it was originally
> intended, for instance see: http://www.joelonsoftware.com/articles/Wrong.html
> for a discussion of the original intent (I'm assuming Joel is correct here -- I
> haven't tried to check).  The wikipedia article (with its distinction between
> the "apps" and "system" flavours of hungarian notation) is also informative.
Thank you for that! This makes a lot of sense on how the "System 
Hungarian" came into place.  I'll admit that I've used similar concepts 
to "Apps Hungarian" without realizing it.  I'll have to go through 
Joel's site a little further sometime. Actually, even some of the Word 
examples or relatively close to what I've used (absolute position vs 
relative, etc...)
>
> But it doesn't depend all /that/ much.  My answers are "ugh!" and "no" in both
> cases, albeit for somewhat different reasons.

Like you Chris, I disagree with Joel's conclusion to a point.  If you 
can offload the "kind" checking to an automatic static analysis tool 
(such as the compiler), you're better off than encoding "kind" 
information in the naming convention.

To talk about Joel's example of the safe vs unsafe string, I would 
prefer several class types over this naming convention (especially since 
"safe" is actually context dependent).  Actually, what I'd love from 
some of my favorite languages are annotated constraints that affect type 
checking (static or dynamic).

Hmm, there's an idea forming in my head now...

A "type" could have several parts to it.
   1. Interface. Defines the contract for the caller and the object.
   2. Constraints. Defines additional constraints on what can be done 
with this type. Things like whether a pointer/reference may contain 
"null", valid integer ranges (non-negative, etc...).
   3. Implementation. The actual object code that executes to handle the 
objects side of the contract defined by the interface.

Using Joel's example, and psuedo Java notation, you would end up with 
the following signatures.

@UserInput String Request(@Safe String parameterName);
@Safe String SafeFromUserInput(@UserInput String parameterName);
void Write(@Safe String);

so Write(Request("foo")); could either be a type error, or an automatic 
type conversion, depending on your preferences (this is a whole other 
debate).  No longer relying on human eyes to "spot" the wrong code, but 
allowing your tools to do so for you.

Sorry for the stream of consciousness here ;-)

Thanks,
Daniel.

[toc] | [prev] | [next] | [standalone]


#1930

FromBGB <cr88192@hotmail.com>
Date2012-07-09 22:13 -0500
Message-ID<jtg6po$lni$1@news.albasani.net>
In reply to#1911
On 7/6/2012 4:01 PM, bob wrote:
> What do you all think of Hungarian notation?  Is this worth using?
>

it can be useful sometimes.
in general, not so much.

if used extensively or poorly, it can make code look terrible.

if in doubt, probably it is better off not being used.


cases where it can be useful:
when a variable serves a particular role, then a prefix can help 
identify a role;
when there is no clearly better way to come up with unique variable 
names (usually results in "s0, s1, s2" and "i0, i1, i2", and similar, 1).

1: some people say to come up with symbolic names for variables, but 
sometimes this itself is a problem, as there is not always a good "name" 
for the value being held, and at the moment it is more just needed to 
have "somewhere to hold a value of type X".

this is especially common in things like math-related problems, or 
things involving manipulating structured data, where one ends up needing 
a lot of temporary variables mostly to hold the various pieces of data 
one is working with.


cases where Hungarian it is not so useful:
identifying data types (2).

2: the compiler already does this, and if we already have a good name 
for a variable, then there is little need to identify its type.

for example, 'strName' is possible, but kind of pointless:
if we know that it is a name, and that names are strings, then there is 
little real point in making this be a part of the variable name (better 
to invest effort instead either in coming up with a "better" name, or 
putting something actually relevant as a prefix, ...).


in my case, this leads to certain situations for where Hungarian or 
similar is used, with it not being used for the most part / in-general.


but, a lot depends.

[toc] | [prev] | [next] | [standalone]


#1944

Frommalcolm.mclean5@btinternet.com
Date2012-07-14 13:52 -0700
Message-ID<7d907e7f-cdba-4b3c-acb3-a63783770fd6@googlegroups.com>
In reply to#1911
בתאריך יום שישי, 6 ביולי 2012 22:01:58 UTC+1, מאת bob:
>
> What do you all think of Hungarian notation?  Is this worth using?
>
Generally I don't use it. I give my variables names like i for a loop counter, x and y for algebraic variables or Cartesian co-ordinates, and often the distiction between the two is a bit fuzzy, N for a count of items in memory, str for a string, buff for a memory buffer, width and height for image dimensions, temp for a temporary variable, flag for a boolean.

That serves for most low-level functions. For higher level functions, I do use something similar, but, because of the nature of higher-level objects, the nomenclature has to be rather ad-hoc. I give buttons the suffix _but, edit boxes _edt, labels _lab, and so on. But often there's an existing convention for a window. I also use a similar prefix for items that are tightly dependent on a library. So I might use x or X_ for things that only make sense in a X windows context, GL for open GL, QT for QT things, and so on.

[toc] | [prev] | [next] | [standalone]


#2038

Fromlawrence.jones@siemens.com
Date2012-08-08 14:57 -0400
Message-ID<scpaf9-ram.ln1@jones.homeip.net>
In reply to#1944
malcolm.mclean5@btinternet.com wrote:
> ???????????? ?????? ????????, 6 ?????????? 2012 22:01:58 UTC+1, ?????? bob:
> >
> > What do you all think of Hungarian notation?  Is this worth using?
> >

> Generally I don't use it. I give my variables names like i for a loop
> counter, x and y for algebraic variables or Cartesian co-ordinates, and
> often the distiction between the two is a bit fuzzy, N for a count of
> items in memory, str for a string, buff for a memory buffer, width and
> height for image dimensions, temp for a temporary variable, flag for a
> boolean.

Guess what... that *is* Hungarian notation (as originally conceived, not
as it's been perverted into).
-- 
Larry Jones

Oh, now YOU'RE going to start in on me TOO, huh? -- Calvin

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming


csiph-web