From: Mathieu Bouchard Date: 2001-10-31T23:33:25+09:00 Subject: [ruby-talk:23951] Re: RCR: Fun with attribute shortcuts solves RCR #3 and more On Tue, 30 Oct 2001, Albert Wagner wrote: > > the method is the usual one. Macros and metaprogamming are not about > > obfuscation - quite the opposite, in fact. The more you can bring > > explicit design concepts and vocabulary into your code, the better. > Sorry. I guess I needed more smiley faces. Still...how long would it > take a newbie (or anyone as slow-witted as myself) to figure out what > was happening here? After scouring the pickaxe for the construction I > would plague the NG with yet another stupid question. There is a very > thin line between flexibility and chaos. You gurus be careful. In every system there's a tension between writing code that is familiar to everyone at first sight, and writing code that requires some more knowledge but has some _special qualities_. Those latter would be: more obvious at _second_ sight (PoLS), shorter code, no redundancy (the DRY principle), written in the words the author used to think about the code ("pseudo-code" qualities), less bugs in the first place ("debugging by prevention"), easier to debug, easier to modify and more uses for the same piece of code (flexibility). Also, this is Ruby, so you should expect that Ruby-specific combinations of features actually gets used: in this case, "class methods", eval(), and run-time program modification. If Ruby-specific features are not used, then why not choose another language, e.g. Python. I occasionally bash my head on advanced concepts from time to time; but my assumption is that learning (and getting experience) on advanced features is much rewarded by how much grunt work you can save; so I don't mind sitting a bit to do the necessary thinking. If you have difficulties understanding how classes and objects are connected together (down to singleton metaclasses), maybe the box-and-arrow notation (as used in some parts of Pickaxe) is a good way to visualise. I personally think it's helpful and that a visual "debugger" for Ruby should be able to do that on a real object space. ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju