Alexy,

although I am not Adrian, I still felt compelled to comment. :)

On 12/13/05, braver <[EMAIL PROTECTED]> wrote:
> class Project(meta.Model):
>   project_manager = meta.ForeignKey(ProjectManager)
>   milestones = meta.OneToOneField(Milestone)
>   categories = meta.ManyToManyField(Category)
>
> p  = projects.get_object(id__exact=1)
> pp = projects.get_list
>
> ...over:
>
> class Person < ActiveRecord::Base
>   belongs_to :project_manager
>   has_many   :milestones
>   has_and_belongs_to_many :categories
> end
>
> p  = Project.find(1)
> pp = Project.find(:all)

I find the class extension of Ruby less clear than Python's, however I
can understand how people might prefer Ruby's use of English
keywords/functions to build the model.  However, what I wonder about
though is how often you need to jog your memory or turn to reference
documentation to realise what 'belongs_to' exactly means.  To my first
reading it is not immediately clear that it has a foreign key
relationship.  Of course one may wonder if that kind of knowledge is
needed at all. I personally do not care much for the use of so many
underbars/underscores in the Ruby code.

I do agree that p = Project.find(1) is more intuitive than p =
projects.get_object(id__exact=1), since one can wonder why on earth
the terminology of an object has to be repeated, although the name
find wouldn't be my first choice, I'd settle for get().  On the other
hand, get_list() (or perhaps get_all?) is more intuitive over
Projecy.find(:all), especially if combined with the previous comment
of get().

The repeating of meta might be an eyesore to some people's view, but
it at least provides for solid namespacing, although you could of
course wonder how descriptive meta is.

Just some of my thoughts. :)
I am sure that a lot of this is highly dependent on the person in question.

--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
Free Tibet! http://www.savetibet.org/ | Je maintiendrai!
http://www.in-nomine.org/ | [EMAIL PROTECTED]
Teaching should be such that what is offered is perceived as a valuable
gift and not as a hard duty...

Reply via email to