|
Hungarian notation is one of those topics of great debate in the programming community. You can find just as many intelligent and well-respected proponents as you can find opponents advSome nsubjPeople vbThought adjBetter?
Probably made a few errors in that one. I never did learn sentence diagramming.
|
|
|
|
|
Wow, that was inane. What went wrong? Well, take this:
No more guessing, and no more scrolling back to check the type.
One of the things that "went wrong" is that IDE's became more sophisticated so you merely mouse over the variable to find out its type.
And then:
Hungarian notation hasn’t gained full acceptance from the development community.
Of course, because life was simple when you worked in C. You had built in variables, and ok, structs. With OOP, if you used Hungarian notation, you'd have:
cListCtrlListOfPeople = new CListCtrl()
or some BS like that. You can't Hungarian-ize all the types that are created in OOP without going nuts.
Which brings me to my other point -- conflicting styles.
When we use loosely-typed languages, we’re using them for a reason!
I've actually never seen a loosely-typed language used for that reason. It's pure laziness IMO. On the other hand, yeah, I have replaced entire class implementations in Python with a mock class and the type-less language doesn't care as long as the methods are implemented the same. But IMO: It's dangerous, the code becomes confusing to understand, and worse, changes can easily break things, as you have no idea what other concrete square is being shoved into the round hole (ok, that's a bad image) which, IMO again, is one of the primary reasons unit testing was invented -- a problem that was created to solve another problem.
Following standards and best practices makes our code readable, and Hungarian notation is just one of many standards and best practices.
Riiiight. So, instead of x = YouHaveToGuessWhatIAm(); we can write strX = You HaveToGuessWhatIAm();
I'll stop now.
|
|
|
|
|
I like and use Hungarian for screen controls - I find it makes code genuinely more readable if I can instantly spot a radio button from a check box or a text block from a stack panel in the code behind.
In all other circumstances, it's a complete and utter absurdity in the age of IDEs and Intellisense. Though, come to think of it, I found it a complete PITA back in the days when we coded in vi rather than Visual Studio - *ptrSomethingOrOther is so spectacularly redundant that it hurts the eyeballs.
98.4% of statistics are made up on the spot.
|
|
|
|
|
PeejayAdams wrote: I like and use Hungarian for screen controls -
Me too! That's the only time I use Hungarian notation.
|
|
|
|
|
But is it Hungarian Notation? For example, naming an edit control "portEdit" is not using Hungarian. Hungarian originally mean that the purpose of the variable was prefixed by a letter, though that eventually became the type, which was truly annoying when you had stuff like "iCount", which was actually unsigned (and redundant) or code which used 'b' for both "byte" and "bool".
So, what would portEdit be? ePort?
And that is a big reason Hungarian Notion died--nobody agreed on anything except p, i, s, sz and sometimes d (delta), though the latter three were very inconsistent and 'i' was often just prefixed to anything that wasn't a string. I still do use "p" for naked pointers since knowing something is a naked pointer is really important, especially in C++.
EDIT: Just remembered three more places I use Hungarian--h for raw handle, as in hWnd or hFile--and wParam and lParam, though the notation no longer has anything to do with the type.
modified 13-Dec-17 11:49am.
|
|
|
|
|
Fair point, we should probably talk about "type indication" or some such phrase rather than HN.
As an aside, I kind of love the code example in Simonyi's original paper:
1 #include "sy.h"
2 extern int *rgwDic;
3 extern int bsyMac;
4 struct SY *PsySz(char sz[])
6 {
7 char *pch;
8 int cch;
9 struct SY *psy, *PsyCreate();
10 int *pbsy;
11 int cwSz;
12 unsigned wHash=0;
13 pch=sz;
14 while (*pch!=0
15 wHash=(wHash<>11+*pch++;
16 cch=pch-sz;
17 pbsy=&rgbsyHash[(wHash&077777)%cwHash];
18 for (; *pbsy!=0; pbsy = &psy->bsyNext)
19 {
20 char *szSy;
21 szSy= (psy=(struct SY*)&rgwDic[*pbsy])->sz;
22 pch=sz;
23 while (*pch==*szSy++)
24 {
25 if (*pch++==0)
26 return (psy);
27 }
28 }
29 cwSz=0;
30 if (cch>=2)
31 cwSz=(cch-2/sizeof(int)+1;
32 *pbsy=(int *)(psy=PsyCreate(cwSY+cwSz))-rgwDic;
33 Zero((int *)psy,cwSY);
34 bltbyte(sz, psy->sz, cch+1);
35 return(psy);
36 }
Readability is certainly not a word that I'd associate with it.
98.4% of statistics are made up on the spot.
|
|
|
|
|
Joe Woodbury wrote: the notation no longer has anything to do with the type
It was never intended to be anything about the type. It was meant to provide extra info about what the var was being used to hold and what its units were. It was MS that used it for type, losing a lot of its usefulness.
E.g.
float fDistance;
float kmDistance, milesDistance, inchDistance;
|
|
|
|
|
Congratulations for reading something entirely out of context, which, ironically, proves the point I made. It was EVERYONE who used it for type, not just Microsoft (where Simonyi worked.)
Incidentally, and to be pedantic, your examples are NOT strict Hungarian notation, which further proves my point that nobody really understood the damn thing.
My point in your out-of-context quote is that even wParam has lost that secondary meaning Hungarian wise. However, as a whole its linguistically valid since it does describe the intent. When I say "wParam" to a Windows developer, they know what I'm talking about.
|
|
|
|
|
Back in the day I used to love it. Now I hate it.
Kevin
|
|
|
|
|
I find hungarian notation useful inside algorithms, as it makes very clear the types involved in an operation (which is necessary to know in order to maximize the computation precision) and inside private member functions, for the very same reason.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
I use Dungarian notation, thats where I put all the useless letters at the end.
|
|
|
|
|
In my opinion, nothing went wrong. It was just a case where strongly-typed languages and sophisticated IDEs made it unnecessary and more of a hassle than it is worth. Before the nice IDEs it was moderately useful as a way to save time but that was then and most of us have since moved on.
|
|
|
|
|
That only killed bad (system) Hungarian; not good (application) Hungarian.
|
|
|
|
|
Yes, that is true. I sort of look at it as Microsoft-style HN, the bad sort, is what has died.
|
|
|
|
|
PIEBALD whips out his Schwartz again... Making Wrong Code Look Wrong – Joel on Software[^] (OK OK, not technically a Schwartz, but close.)
It was killed by misunderstanding. And never was worthwhile even when it was understood.
Mostly just another case of senior developers not trusting junior developers.
|
|
|
|
|
For an article that promises a post-mortem on what went wrong, the part that was missed was the actual post-mortem.
This space for rent
|
|
|
|
|
|
Broadband services are a wonderful innovation of our time, using multiple frequency bands (hence the name) to carry signals over wires (usually, copper, sometimes aluminium). One of the key aspects of the technology is its ability to adapt to the length and characteristics of the line on which it is deployed. Pfff. My ISP already proved that
I guess it was a busy day in the office?
|
|
|
|
|
|
When the Internet started to become widely used in the 1990s, most traffic used just a few protocols: IPv4 routed packets, TCP turned those packets into connections, SSL (later TLS) encrypted those connections, DNS named hosts to connect to, and HTTP was often the application protocol using it all. 1/2 of HTTP, and more
No, it's not a Net Neutrality post
|
|
|
|
|
We need to invent a real C3PO.
|
|
|
|
|
An actually interesting article about protocols. Thanks Kent!
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
We aim to please. You're very welcome.
TTFN - Kent
|
|
|
|
|
Ch-ch-ch-ch-Changes
(Turn and face the strange)
Ch-ch-Changes
Just gonna have to be a different man
Time may change me
But I can't trace time
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
Russian billionaire Yuri Milner says if the space rock 'Oumuamua is giving off radio signals, his team will be able to detect them—and they may get the results within days. We can ask them where are they going (and can we come too?)
|
|
|
|