From: "David A. Black" Date: 2007-10-19T01:18:36+09:00 Subject: Re: Naming Conventions Hi -- On Fri, 19 Oct 2007, John Joyce wrote: > > On Oct 18, 2007, at 9:27 AM, David A. Black wrote: > >> Hi -- >> >> On Thu, 18 Oct 2007, John Joyce wrote: >> >>>> The choice is yours. :) >>> Yes. You can do as you please. >>> >>>> Where the style counts more though is in terms of casing. So for >>>> instance: >>>> * Constants start with a capital letter. >>>> * Method names are in snake_case. >>>> * Class names in CamelCase. >>> >>> ModuleNames are also camel cased. >>> >>> Other tip: >>> use do and end for multi-line blocks >>> use {} for single line blocks >>> It's not a rule, just by convention. >>> >>> Other other tip: >>> Rails is not necessarily an example of Ruby. It's an example of Ruby's >>> tendency to become a DSL. >>> Many gems will show you different looking but similarly developed >>> not-typical-Ruby-looking style. >>> There seems to be a tendency for DSL-like things in Ruby projects as they >>> get developed. >>> I think this is a result of Ruby being very very OOPy and very flexible. >>> So don't be surprised when some things seem to have their own conventions >>> contrary to "standard" (?!) Ruby >> >> On the other hand... Rails does a lot of things in conformity with >> traditional Ruby style, which I think is very good and perhaps very >> shrewd. The main departure is a lot of method calls without >> parentheses. But the Rails code adheres to two-space indenting, >> standard use of this_style and ThisStyle in the appropriate places, >> and other standard stylistic things that people are often fond of >> pushing aside. >> >> >> David >> >> -- >> Upcoming training from Ruby Power and Light, LLC: >> * Intro to Ruby on Rails, Edison, NJ, October 23-26 >> * Advancing with Rails, Edison, NJ, November 6-9 >> Both taught by David A. Black. >> See http://www.rubypal.com for more info! >> > True True, one must admire the dedication in Rails to consistency! It's a > rare beast that you see more or less what you expect to see as you dig > deeper. > > I was simply referring more to the DSL type things, such as Rails' > associations and validations, and of course Active Record itself. But the > beauty is that from the Rails Console, everything feels like any other irb > session and feels like typical Ruby. > > Other tools though, like Rake, must be mystical to the Ruby newbie. > Some Ruby gems even seem like DSLs because of Ruby syntax after people come > from something like C or PHP. And of course there's the matter of the term DSL itself, and what it connotes (or doesn't). See for example: http://dablog.rubypal.com/2007/4/17/the-l-in-dsl-langue-ou-langage David -- Upcoming training from Ruby Power and Light, LLC: * Intro to Ruby on Rails, Edison, NJ, October 23-26 * Advancing with Rails, Edison, NJ, November 6-9 Both taught by David A. Black. See http://www.rubypal.com for more info!