Sign in to follow this  
Followers 0
mhagain

Hungarian Notation taken too far

9 posts in this topic

Good old Variants.. you never know what they really are. Delphi had those too (along with the more standard data types) but they are just confusing to use.

0

Share this post


Link to post
Share on other sites
That's not far enough! All code that uses vntBlah should be contained in a string that's eval'ed, so the prefix can be replaced with the appropriate type whenever it's used!!!

For serious though: I always have the urge to point out that this isnt real Hungarian notation; it's microsoft's pervertion, 'systems Hungarian'.
1

Share this post


Link to post
Share on other sites
For those who apparently missed it, the old VBScript had exactly one data type: Variant.

With exactly one data type there is no point to attempting to mark what type it is.
3

Share this post


Link to post
Share on other sites

Good old Variants.. you never know what they really are. Delphi had those too (along with the more standard data types) but they are just confusing to use.

 

I guess a question can be asked here:

is a language with both static types and variants:

A, a statically typed language with variants as a sub-type;

B, a dynamically typed language with optional explicit type-specialization.

 

or, does it depend more on what magic goes on within the implementation?... (more values as tagged or untagged?...)

or, on the declaration syntax?... ("var x; var y:int;" vs "var x; int y;").

or, edge-case behavior (say, "long" only able to directly encode +-(2^61) and having to sometimes escape-code values outside this range, or very large/small doubles sometimes losing several bits of precision?... as a result of internal conversions to/from variant).

 

(in my case, this is one of those unanswered questions regarding whether to classify my script-language as statically or dynamically typed... then again, compared with other similar languages, it would probably be classified as statically typed, despite the frequent use of dynamic types in many places...).

 

 

I guess this sort of fits in with whether one indicates the type of a variant in a variable name:

is a variant the absence of type, or instead its own type within a collection of other types?...

 

(well, along with the whole matter of whether objects or variants are the conceptual root-type for the type-system, ...).

Edited by cr88192
0

Share this post


Link to post
Share on other sites

Considering you're normally supposed to use non-Variant types, I'd say it falls under A.

 

Also ugh, I completely hate Hungarian notation, and that it's misused doesn't help. If you're going to use it then at least use it properly! (it's supposed to indicate what kind of data is stored (e.g. pxWidth would mean width in pixels), not what type of variable is it).

1

Share this post


Link to post
Share on other sites

Considering you're normally supposed to use non-Variant types, I'd say it falls under A.

 

Also ugh, I completely hate Hungarian notation, and that it's misused doesn't help. If you're going to use it then at least use it properly! (it's supposed to indicate what kind of data is stored (e.g. pxWidth would mean width in pixels), not what type of variable is it).

 

yeah, makes sense.

 

at least in my case (with my scripting language) using explicitly declared types can help significantly WRT things like performance, and also makes the compiler/interpreter better able to give useful errors and warnings, so this itself may be reason to use it, and likely puts things more in the statically-typed camp.

 

this is even if internally, tagged references are still often used, knowing the types often allows much cheaper logic to be used (allowing doing things directly, without all the type-checking and dynamic-dispatch and similar getting in the way).

 

...

 

so, you saying you don't like things like "LPCSTR szaStr;" or "DWORD dwSz;"?...

0

Share this post


Link to post
Share on other sites


Also ugh, I completely hate Hungarian notation, and that it's misused doesn't help. If you're going to use it then at least use it properly! (it's supposed to indicate what kind of data is stored (e.g. pxWidth would mean width in pixels), not what type of variable is it).

so, you saying you don't like things like "LPCSTR szaStr;" or "DWORD dwSz;"?...
Yes, that's not actually Hungarian notation. That's some perversion created by someone at Microsoft who misunderstood the original idea. Within Microsoft they call this incorrect version "systems Hungarian" and the correct usage "apps Hungarian".
In the former you prefix with primitive/data-structure types, in the latter you prefix with semantic types (this length is in meters, this string uses HTML encoded characters, this 'count' is how many columns there are, etc).
2

Share this post


Link to post
Share on other sites

Yep, pretty much. Generally I'd prefer if the name of the variable and the context by itself would be enough (if it isn't then you may want to rethink the design to make things clear enough). I guess Hungarian notation makes sense with complex projects handling all sorts of data (though in those cases I'd opt for more explicit variable names instead), but fake Hungarian notation is just a complete annoyance (if you can't tell the type by what the variable is supposed to do you have more serious issues), especially now that IDEs can help you look up the types of variables (so you don't need to do it in the source code at all).

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0