[Nitro] Nitrous blog category and categories

Robert Mela rob at robmela.com
Sun Sep 9 00:34:47 EDT 2007


I think the Rails convention of tablename := pluralized modelname is 
like so totally Yuck-O-la. 

So I'm bummed to see it in the Nitro blog example.

The rationale, I suppose, is that by changing, e.g., "bicycle" to 
"bicycles" we indicate that the table is a set of bicycles:

  "bicycle" + "s" = table or set of bicycles

But the saying "table of" or "set of" already means there may be more 
than one.   Changing the morphology is redundant.

The plural is also flakier.   Consider a "category" table with one row.  
So we refer to one category as categories?

It gets a little confusing.   In app.rb for the blog example there's:

     app.dispatcher.root.comments = Comment
     app.dispatcher.root.categories = Category

I had to add a "to_link" method to the models to get the demo to run.  
In category.rb I added

class Category
  def to_link
      "<a href='/category/view/#{oid}'>#{title}</a>"
  end

... but the dispatcher path is /categories/!  D'oh!

And in Rails we type "Category.find" to get many categories from a table 
full of categories....

The morphology of pluralization is an artifact of the European grammars 
burned into our brains.  Think of Japanese.   Would a Japanese 
programmer be at any disadvantage for the lack of pluralization in her 
table names?

Heck, case and gnarly verb conjugations are part of how we think.   We 
don't add those to our programming conventions ( except in variable 
names ).   So why bother with plurals, when

1) the information it's intended to convey is already clear from context
2) It's excess code
3) It's complicated
  -- elk -> elk
  -- does it do latin?
  -- Is it available in Finnish
  -- what about the languages where it's a no-op?
4) It introduces inconsistencies in usage ( Category.find -- looks in a 
group of many categories, may return many categories... etc.)

I bet the reason plurals are part of the convention is because...uh, 
because we can.  A few simple rules, and a dictionary for the exceptions....


-------------- next part --------------
A non-text attachment was scrubbed...
Name: rob.vcf
Type: text/x-vcard
Size: 116 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20070909/29ea8760/attachment.vcf 


More information about the Nitro-general mailing list