T. Onoma
11/12/2004 8:41:00 PM
The argument that #init should be available to end users like #id is very weak
b/c 'id' is very common, especially in DB work (where it is essentially
required). I have never had a need for my own #init, nor seen any other code
that required such --i.e. made things troubling for the lack of it.
The main point as to why #init is much better, is simply to do with saving
time. Add up all the time you save typing those extra 6 characters. Lets say
it takes you 1/2 second to type (give or take depending on how fast you
type). In a year I would guess that I type 'initialize' multiple thousands of
times, as I'm sure many Rubyists do. Well, for every 1200, that's nearly an
hour of my life. Between a 100 Rubyists, that's 100 man hours wasted! Worse
is when I've accidently mistyped it, which always happens somewhere in those
last six characters. I mistype it maybe 1-2% of the time (I've gotton better
at it over time). For each of those I waste a minute or two finding and
fixing the typo. There goes another hour of my life (and many more total man
hours for our Rubyists).
'initialize' is easily in the top 5 most typed ruby words, like 'def', 'if'
and 'class'. Such words really ought to be short for this simple reason.
T.
P.S. Not to mention all the time spent by people thinking the above and then
spending time to tell other people about it ;)