Paranoid Programming – Techniques for Constructing Robust Software [ps]
ftp.stratus.com
ftp.stratus.com
UPDATE: found a free web based service to convert it to PDF for me, docspal.com
(Just trying to be helpful, I hope I'm not infringing anything?)
It seems that this recommendation to a large degree is a reflection of tools used. Nowadays it wouldn't be completely unusual for an IDE to show formal parameter name along with actual argument values passed, thus obviating the need to encode this information into the function name in the first place.
Idea of robust data structures is very interesting. While storing additional information to detect potential misuse of API, like concurrent modification or iterator invalidation is common in other context, the idea of using it to correct the data structure is not the first thing that comes to mind.
None of this is enforced at the tools level.
The prefix wouldn't necessarily be only a single character. For example, using a "p" prefix for pointer values was a common convention in Microsoft ecosystem projects where Hungarian notation was probably most popular. Thus a pointer-to-char (char*) parameter might be prefixed with "pc".
But yes, the fundamental idea was to convey information about the type of the variable as part of its name. That convention has mostly died out today, probably due to a combination of IDEs being used routinely in the ecosystem where the notation was most popular, and more recently due to modern languages having better type systems that enforce the rules objectively instead of relying on a convention.
Ironically, with the popularity of dynamically typed languages today, we sometimes seem to have regressed to a point where interfaces to functions aren't always clear, and lots of avoidable bugs creep in due to passing incorrect types of data around. The emphasis on rapid evolution and ad-hoc/organic design we see with a lot of "agile" development processes isn't always helpful either. Put those together, and you almost have the complete opposite of the systematic design and robust processes advocated in the slides here.
No.
There are two types of Hungarian Notation.
The original one ("apps hungarian"), which made sense and sometimes still makes sense. Here you would assign a meaning to a prefix. For example, if you're writing MS Word a variable named "sWidth" might be the width of something in pixels on the screen (s), while "pWidth" might be the same width, but in logical units (say pt) on the page. Then you could have a function ptos, and it's easy to see whether variables were used correctly in computations - you can't mix screen-space and page-space coordinates without conversion.
This made a lot of sense, because either variable would likely just be an "int".
Similarly in a Python Webapp one might write "us_name" where us means UnSanitized. So before passing that anywhere else you know you need to sanitize it. See a "us_" variable somewhere that isn't a call to a sanitizer? Probably a bug!
Then there's that other one, "system hungarian", which is the stupid thing everyone knows with stuff like lpcstrWindowName.
EDIT: people often see these as prefixes, but they are not really prefixes, the original paper was about the whole name.
In modern languages where defining custom types and enforcing their use is easier, there is less need to distinguish these properties by convention. Twenty years ago, when we were doing more development with languages in the C family that don't have very powerful systems, it was a different story, and so naming conventions went some way to helping keep track of what data you were really passing around beyond just "It's an int" and the like.
This is, after all, exactly how systems hungarian misunderstanding came about.
It's just that nobody ever actually does that in C++.
sh-i-sh-k-eb-ab-----
I can see it!
Choo-Choo-Train
I can see it!
So, carry on...
So now you have stuff like:
view.convert(point, to: otherView)
Which in Swift 2 was:
view.convertPoint(point, toView: otherView)
Martin claimed in the very same book several ridiculous things (like not documenting short functions, which makes autogenerated documentation look awful; apparently Martin haven't ever used documentation generators before writing the book).
It's hard to take Martin's recommendations as coming from "the industry".
I read (see below) that the idea of Hungarian notation was bastardised. The idea wasn't to encode type information as such, not in the primitives type sense. It was more to encode meaning succinctly.
To use the example given, Position(x, y) is perfectly fine in Hungarian notation, because the variables tell us exactly what they are: the x and y coordinates as part of a point. The Hungarian notation we rip on would have us write Position(ix, iy).
With the tools and type systems today, yeah, it's obsolete in the truest sense. Interesting piece of history none the less. I guess the real usefulness is the idea of encoding verbose information that our current tools and language do not support. That sounds better than encoding a primitive.
https://blogs.msdn.microsoft.com/rick_schaut/2004/02/14/hung...
For anyone who's only ever worked on projects where the emphasis is more on shipping something fast than shipping something correct, like most of the startups and web apps we discuss here on HN, these slides give a decent overview of the "alternate reality" when you're working on projects where reliability really matters and more of an engineering mindset is needed.
If nothing else, it's worth reading for the Ariane 501 case study on slides 19-22 that demonstrates just how expensive a simple programming error can be if you don't design your system defensively enough and do proper housekeeping on your code.