Skip to main content
13 events
when toggle format what by license comment
Aug 24, 2016 at 11:00 comment added Ewan I should point out that I'm not actualy recommending not prefixing interfaces with I. just saying if you want to remove the prefix, namespaces are better than suffixing the implementation with 'Concrete'
Aug 24, 2016 at 9:05 comment added Vinko Vrsalovic @luaan did you see the examples I used? Do they look unusable? No need to cherry pick an artificially long example which makes no sense in modern languages to make your point. I agree that for 'old' languages Hungarian makes sense, but that was my point when I said we can do better now, using more modern languages. If you are stuck with C, do go on using Apps Hungarian.
Aug 24, 2016 at 9:00 comment added Luaan @VinkoVrsalovic For some cases, yeah. But do you really write names like FirstnameLongPointerToANullTerminatedString? Semantic hungarian notation is still very useful, you just have to make sure it's worth the cost of teaching the meaning - you will need to do a lot of teaching for any newcomer anyway, don't pretend they just magically follow the same guidelines you do, even if you both base them on the same document. Strict typing would be preferred in most cases, of course, which is why hungarian isn't used so much in languages like C# and modern C++.
Aug 24, 2016 at 1:28 comment added Wildcard @JoshuaTaylor, thank you for linking that article.
Aug 23, 2016 at 20:17 comment added Vinko Vrsalovic @CodyGray I agree with the value of hungarian notation, but now we can do better than it: use actual descriptive names, like CheckBoxXCoordinate, NameCharCount, IsCheckBoxVisible, FilePointer, WindowHandle, so there's no need to use that notation because vars can be more descriptive without having to understand and remember a specific notation. NameCharCount + CheckBoxXCoordinate is even more evidently wrong than xControl+cchName
Aug 23, 2016 at 17:24 comment added Joshua Taylor @CodyGray Joel Spolsky wrote a nice article, Making Wrong Code Look Wrong about Hungarian notation and the ways in which it's been (mis)understood. He has a similar opinion: the prefix should be a higher level type, not the raw data storage type. He uses the word "kind", explaining, "I’m using the word kind on purpose, there, because Simonyi mistakenly used the word type in his paper, and generations of programmers misunderstood what he meant."
Aug 23, 2016 at 14:44 comment added Ewan the good ol' days you mean, before all this longVariableNamesAreGoodForSomeReason nononsense! (or gdOD -beforeNsense as i call it)
Aug 23, 2016 at 12:59 comment added user "In the old days" compilers were often severely limited in identifier lengths; something like 6-10 characters was common. You could use longer names, but the part beyond the first few characters was not considered for variable name uniqueness. I think at least in Turbo C 2.0, the length was even configurable!
Aug 23, 2016 at 12:22 comment added Cody Gray There is still a lot of value in this. A compiler is not going to catch the error when you add xControl to cchName. They are both of type int, but they have very different semantics. The prefixes make these semantics obvious to a human. A pointer to a NUL-terminated string looks exactly like a pointer to a Pascal-style string to a compiler. Similarly, the I prefix for interfaces emerged in the C++ language where interfaces are really just classes (and indeed for C, where there is no such thing as a class or an interface at the language level, it's all just a convention).
Aug 23, 2016 at 12:19 comment added Cody Gray I believe you are thinking of Hungarian notation, in which you did indeed prefix names with types. But there was no time in which you'd write something like intCounter or boolFlag. Those are the wrong "types". Instead, you'd write pszName (pointer to a NUL-terminated string containing a name), cchName (count of characters in the string "name"), xControl (x coordinate of the control), fVisible (flag indicating something is visible), pFile (pointer to a file), hWindow (handle to a window), and so on.
Aug 23, 2016 at 9:15 comment added Ewan no its all about making up conventions and blogging about how they 'improve readablity'
Aug 23, 2016 at 9:14 comment added user44761 new? old? Wait, I thought programming was more about rationality than hype. Or was this in the old days?
Aug 23, 2016 at 9:11 history answered Ewan CC BY-SA 3.0