From: Steve Litt Date: 2005-12-08T23:58:17+09:00 Subject: Re: They say I write Ruby like Perl On Thursday 08 December 2005 09:29 am, Bill Guindon wrote: > On 12/8/05, Chris Game wrote: > > Ryan Leavengood wrote: > > > 1. The general naming convention is lowercase with underscores for > > > variables and methods. You have sort of a mix of > > > "runitalltogether" variables, i.e. prevsibling, and then the > > > CamelCase methods like insertSiblingAfterYou. Those should be > > > prev_sibling and insert_sibling_after_you (though that last one > > > is a bit too long.) > > > > Who says? Just a style/convention issue surely. Readability doesn't > > suffer, nor does execution. > > Personally, I think readability does suffer. The wordier it gets, the > more I have to think. Why not a simple 'append_sibling'? This is a special case of the Node.pm/Node.py/Node.rb tool. I wanted the application programmer (the guy *using* the tool as opposed to the guy authoring it (me)) to be able to know exactly what the method does, at a glance. I wanted it to be abundently clear that it was appended to the current object, and not to something else. For instance, if the programmer got a little confused he might think the object was what was being inserted (perhaps inserted into the argument???) I was trying to have the code serve as documentation. Looking at it from hindsight, I probably could have called them append_sibling() and prepend_sibling(), and figured it would be obvious that the argument was what was being inserted, and the object was what the argument was being appended or prepended to. Unfortunately I cannot change this at this point because there's a lot of code using Node.pm, and possibly some using Node.py, so I can't change it without breaking a lot of programs, and I want to keep the method calls in Node.pm, Node.py and Node.rb as similar as possible. However, the next *independent* software I write, I'll definitely spend some time thinking of more succinct ways to create descriptive variable names. Yep, in hindsight, insert_sibling_after_you might have been overkill. Incidentally, if you ever want to really understand a problem domain, one way is write it in three different languages, and get feedback in all three :-) Thanks SteveT Steve Litt http://www.troubleshooters.com slitt@troubleshooters.com