From: RichardOnRails Date: 2007-11-27T04:55:06+09:00 Subject: Re: False positives in editing data On Nov 21, 8:42 pm, Alex Young wrote: > 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 Hi Alex, > 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) I like that. > If it's denoting a class, > then it's not something I can see as useful I like to know merely by inspection whether a referent denotes an integer, a string, a hash or an array of such things. I'd like to avoid "Syntax error" simply because I failed to include a to_s, to_i, [] or whatever. I really can't see why a prefixed lower-case letter or two before a camel-case object name can create so much discussion irrelevant to the question at hand. Maybe I'll have so "sanitize" all the code I post to exemplify a coding issue. Thank you for your response, notwithstanding my lack of total agreement. Best wishes, Richard