From: Tom Cloyd Date: 2009-07-14T22:31:15+09:00 Subject: Re: Twelve rules of Ruby David A. Black wrote: > Hi -- > > On Tue, 14 Jul 2009, Panu Kinnari wrote: > >> Scott Adams of Dilbert fame talked about learning twelve concepts of >> something and in the progress become more knowledgeable about given >> subject than most of the other people. >> >> Original blogpost here: http://www.dilbert.com/blog/entry/rule_of_twelve >> And followup with actual example: >> http://www.dilbert.com/blog/entry/twelve_rules_of_energy_efficient_building/ >> >> >> Question I am proposing is found in subject line, what would be The >> Twelve Rules for Ruby. >> >> I am not that great programmer and one of the reasons for starting this >> thread is to give some direction to my learning. And then to write more >> code to actually learn. >> >> I am not expecting for everyone to post 12 things, but maybe few that >> they think should be included on this kind of list. > > Here's half a dozen. I would say that if everyone understood these > principles, and really stopped to think about them when puzzled by > something that Ruby was doing, or something that wasn't working in > their code, it would make a huge difference overall to people's > experiences learning and using Ruby: > > 1. Classes are objects. > 2. Objects don't "have" methods; they have the intelligence to resolve > messages by looking for methods along their class/module lookup > path. > 3. Every instance variable you ever see in any Ruby program belongs to > whatever object "self" is at that moment, without exception. (Which > is one reason that understanding how "self" gets assigned is > absolutely vital.) > 4. A code block is a syntactic construct, not an object. 5. Class > variables are not class variables, in the sense of belonging > to a particular class. They are class hierarchy variables. 6. > Inheritance (A < B) is not the same as, and not related to, nesting > (A::B). > > The first one on the list, alone, is worth the price of admission :-) > > > David > Very interesting David. Thanks for these! t. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist Bellingham, Washington, U.S.A: (360) 920-1226 << tc@tomcloyd.com >> (email) << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~