[development] Drupal - to use objects or arrays

Darrel O'Pry dopry at thing.net
Wed Jan 10 21:12:35 UTC 2007


On Tue, 2007-01-09 at 23:08 -0500, Rowan Kerr wrote:
> On 1/9/07, Larry Garfield <larry at garfieldtech.com> wrote:
> > There's no hard rule, but I think "what makes semantic sense when writing it"
> > is the guideline.  Oh yes, and when iterating over records from a database
> > where it really doesn't make a difference, using db_fetch_object() seems more
> > common than db_fetch_array(), simply because there's fewer funky characters
> > involved with objects than arrays. :-)
> 
> I'd be happy to see objects removed completely from Drupal...

I'd have to disagree... I like objects in a lot of ways. I work with
arrays a lot because they're predictable between php4 and php5. There
is, however, some very cool stuff you can do with objects. I wouldn't
like to see Drupal completely excluded from it... 

caveat: I strongly prefer functional programming. I wouldn't want to see
Drupal as an all OO system. Objects used in places where appropriate is
really cool. 

I think what the developer is most comfortable with is the best way... 

For Drupal's sake I remember this discussion from a while back...
Structured Data that doesn't have a variable structure (node, user, etc)
should be objects. More freeform things, like FormAPI, should be
arrays. 

Settling on one or the other would save a bit of type casting here and
there, but that isn't so hard to deal with.

.darrel.



More information about the development mailing list