From: "David A. Black" Date: 2008-12-16T03:38:59+09:00 Subject: Re: Function def at end of scripts Hi -- On Tue, 16 Dec 2008, ara.t.howard wrote: > > On Dec 13, 2008, at 2:11 AM, David A. Black wrote: > >> It can serve a purpose, but please have mercy on those of us who like >> our Ruby in order :-) It's really not that hard to get used to the >> principle that the code (including method definitions) is executed as >> it's encountered, and then you don't have to think about whether or >> not to flip it. > > i like it in order too - logical order that is: > > class Controller > before_filter do > require_user > end > > def action > end > end > > class Model > has_many :children do > def extension > end > end > end > > > the reality is that logical order and organization is far more important, > consider reading a rails app 'in order' ;-) or having to install your own > 'run' hook at the end of every test suite. the reality is that it's > situational - if a script has 50 methods before it gets around to the 'main' > call any sane person might enjoy reading the 'help' method first. this is an > overriding principle of my 'main.rb' lib and i think most people would agree > that reading something like I'm not trying to make any big prounouncements or prescriptions about the concept of order as a software engineering principle. I just don't see code-flipping plus BEGIN {} as a general-usage good way to organize code. There's nothing to extrapolate from this (e.g., about ActiveRecord association semantics); I'm just talking (right or wrong) about this one thing. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2)