I always hated Hungarian notation. I never understood why you needed to indicate the type of the variable in the prefix when the compiler and the IDE would provide that information easily. After reading this article about the origin and original design of Hungarian Notation I am rethinking my opinion. If you have not read Joel on Software before, he usually writes very thought provoking and well reasoned essays. This is no exception:
The premise is that Hungarian was originally to show what kind of value a variable contains, not the type of the variable. This way you can see if you are mixing your apples and oranges, even though they are both of the type fruit. Not sure if I agree with his assessment of exceptions. He raises valid points, but doesn't provide an adequate alternative. Maybe a design practice of not allowing a method to raise an exception, but then your return types become overly complex. I remember calling GetLastError to see if my API call succeeded or failed. Later that method was improved to always checking HResult. Neither hardly seem like a better method then using exceptions.
I will point out that Delphi Win32 still has the best exception handling of any other language I have used. .Net (especially C# in Visual Studio) in comparison. It was Delphi that introduced useful exception handling to the Windows platform, and they still have it right.
Maybe if Joel and Raymond Chen used Delphi they might change their tune about exceptions. Until then I am open to suggestions.
Chris has twice commented on Hungarian Notation too. Be sure you read the article!
No comments:
Post a Comment