From: Alex Young Date: 2007-11-22T10:42:05+09:00 Subject: Re: False positives in editing data RichardOnRails wrote: > On Nov 21, 12:39 pm, Clifford Heath wrote: >> RichardOnRails wrote: >>>>>> sName =~ /^([\d]+)?\.?([\d]+)?\.?([\d]+)?\.?/ >>>> sName >>> Did you draw attention to this because of the Hungarian notation? If >>> so, do you think I'm unwise to adopt the style once advocated by >>> Charles Simoni, super-programmer and co-founder of a giant software >>> company? >> Yes. Adamantly, and definitely yes. >> >> I might have been a bad idea when he had it, even though to his >> credit he was trying to make the best of a bad situation, where >> MS had bought the worst C compiler on the planet because the good >> ones weren't for sale - they could make more money *not* selling >> to MS. Because of a spate of bugs and bad code churned out by the >> MS software factory, many caused by type mismatches on function >> parameters that weren't detected either at compile time or at >> runtime, Hungarian notation *might* have been a good idea once. >> >> It's definitely *not* a good idea with modern C, and even less of >> a good idea with Ruby. >> >> Clifford Heath. > > Hi Clifford, > >> It's definitely *not* a good idea with modern C, and even less of >> a good idea with Ruby. > > I don't know anything about Microsoft's choice of compilers. But I > used several C compilers in the '80s, and all cases found Hungarian > notation helpful. I don't think Microsoft's initial choice of > compilers is relevant to my and other's successful employment of that > convention. > > Why would it be a bad idea with modern C compilers or with Ruby? You > offer no reason. All it does is add one or two letters before names! > That doesn't bother any human or compiler or interpreter. It depends on the type of Hungarian that you're using, and it's not clear from your code sample which it is. If you're using an abbreviation prefix to denote a semantic difference within a type, then that's (potentially) useful, in both Ruby and C: us_username = read_unsafe_input() s_username = sanitise(us_username) with us_ meaning unsafe and s_ meaning safe, for example. Not something I'd use myself, but I can see the utility. If it's denoting a class, then it's not something I can see as useful, in either C or Ruby. In C, you're duplicating the compiler's type-checking, and in Ruby, duck-typing means that you shouldn't need to care; it becomes readability-damaging line noise. -- Alex