Pluralization

Ken Awamura wrote:

I'm aware that Pluralization can be turned-off, but I was wondering why it was created ... just a convention? wouldn´t it be easier if we followed a convention like models and tables in singular, but models with initial capped? ex: Person(class)/person(table)? ... just curious

Firstly, Ruby requires constants, like class names, to begin with a capital letter, and other things not to.

Next, the best way to write a program is for a human to read. Any fool can write a program that a computer can read. Communicating with other humans is a major problem in all computing.

So consider the SQL statement CREATE TABLE users. Without regards to Rails, should that say 'user' or 'users'? There are many users in the table. But you might write SELECT users.name, which looks odd (and not possessive).

So Rails splits this difference by attempting to match the plurality of a table name to its local context. User.find(:all) finds all users. belongs_to :user links your table's items to one user in the users table. has_and_belongs_to_many :users links your table items to many users in the users table. And so on.

The system is not perfect, but it leads one to consider - how literate could my own program be? Could I make my program literate, even at the level of statements' grammar?

Hi --

David A. Black wrote:

Method names can begin with a capital letter too. (Not a practice I'm
eager to encourage, but it's possible :slight_smile:

I thought when you call them, foo.Bar(), that's when the interpretter
trips over them.

Hi --