#141 ✓resolved
Michael Boutros

Multiple Properties With One Call to #property

Reported by Michael Boutros | February 1st, 2008 @ 03:54 PM

As discussed in the IRC channel :)

Benchmarks: http://pastie.caboo.se/146383

Comments and changes to this ticket

  • Adam French

    Adam French February 1st, 2008 @ 09:36 PM

    • State changed from “new” to “open”

    I'm personally not a huge fan of block definitions like this just because it reduces 'glance-ability' of code and makes me have to 'parse' the line in my head to know what's going on now, rather than have property definitions all lined up as if it's arguments were in a table.

    Personal preference, though.

  • Ted Han (knowtheory)

    Ted Han (knowtheory) February 1st, 2008 @ 09:37 PM

    The benchmark i'd need to see met is a compelling reason why

    properties [:field_one, :field_two], :string, :lazy => true

    is better than (i.e. worth the additional code)

    [:field_one, :field_two].each{ |p| property p, :string, :lazy => true }

  • Michael Boutros

    Michael Boutros February 7th, 2008 @ 05:41 PM

    Adam, I agree with you completely and that's why I made sure that no old code would be broken. You can still do it the old way or the new way.

    knowtheory, there is no compelling reason code-wise to do this except for the nicety factor where it looks nicer and it's just easier to remember and write. I personally have grown very fond of:

    property [:one, :two], :string, :lazy => true

    Because it clearly breaks it down and makes it easy to read, and it's much less keystrokes that calling #each. Performance wise, just calling #each is milliseconds quicker (0.000133 seconds), but once again, if those milliseconds are extremely important to you you can always just use the old format.

    There is also a topic in the Google Group where a few people voiced their oppinions: http://groups.google.com/group/d...

  • Sam Smoot

    Sam Smoot February 7th, 2008 @ 10:15 PM

    • State changed from “open” to “resolved”

    So I personally really dislike this... *but*, it doesn't hurt me to add it, and enough people want it...

    Applied in r721.

  • Michael Boutros

    Michael Boutros February 7th, 2008 @ 10:22 PM

    Ah, I accidently left some debug output in the code that got checked in. New patch attached that will apply against r721. And sorry to ruffle so many feathers, I just thought that people would like it more this way :)

  • Adam French

    Adam French February 7th, 2008 @ 11:00 PM

    http://pastie.textmate.org/149114

    ^^ summary of my thoughts regarding multiple property definitions

  • Sam Smoot

    Sam Smoot February 8th, 2008 @ 11:35 AM

    Michael:

    So DM should be most things to most people right? This means as long as no one gets hurt, I've gotta accept that some features I'm not a fan of need to make it in.

    I hope this little brouhaha doesn't dampen your enthusiasm for DM. Regardless of my opinion on what people should or should not like, your contribution is definitely appreciated. :-)

  • Adam French

    Adam French February 8th, 2008 @ 11:20 AM

    yeah, man. Even though I might not be a fan of the syntax, I definitely appreciate your contributions.

    Besides, the more hands on DataMapper, the mo'betta it'll get ;-)

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Attachments

Pages