On Mon, 2006-07-03 at 11:05 +1000, Gordon Heydon wrote:
Hi,
I'm down on consistencies sake. I'm also into the flexability of arrays. Our occasional use of objects don't allow us to do anything useful with them. Where we do have objects, they don't have any methods. So whats the point of keeping them around?
There are a couple of reasons why we do not change.
1. Objects are easier to work with than arrays, but then again, it is 6 of 1, half a dozen of the other.
Not really. There are more functions for manipulating arrays than objects. The functional design of drupal makes methods useless. No inheritance, no private variables(no need for them without methods), basically all the cool stuff that makes OO design worth while isn't used, and can't be without a ground up rewrite of drupal as an OO application. How are they easier -> vs. [' '] come on that's an aesthetic argument. You want to say easier I have at least 10 hours in debugging file api errors that were caused by casting issues where you get arrays from FormAPI, but objects are used for files. See the various casts in upload.module.
2. What is changing going to get us? We would spend the next 6 months moving all the code so that we use arrays over objects, and we will be no further ahead. There is no gain or loss.
+1 more consistent behavior between php4 and php5 creating int arrays is an order of magnitude faster than creating objects. see: http://byster.net/?page_id=36#a2 May not work in our case, but I would definitely like to see real benchmarks of array vs object performance for assigns, creation, passing to a function by reference and as a copy then being returned. memory usage and execution time. $node gets around. I'd like to know that it is in the proper vehicle. as for effort. I heard Karoly volunteering to do regexes to make the job easier, I've already got $file ready to live as an array, but have been holding off on it since I've been focused on my own filesystem.module lately.
3. I remember reading somewhere long ago. Dries likes them over arrays.
I like them, too. I really like them when I can use the things that make them cool. Private vars/protected data space and Inheritance are two biggies for me. plus the whole oo design paradigm which to me is about reusable packaging.
This is like saying nodes are crap, and we should change them to the next greatest XYZ.
No I don't really think so. Nodes are awesome and people can justify it. I think we can base our work and decisions in sound technical judgment and experimentation... One of the things I like about drupal being procedural is we can break the object orientedness as needed. I don't like the way we use objects, because in nearly every case I've seen them, they aren't the right tool for the job there is nothing gained by using an object instead of an array. I think a technical reason for keeping objects instead of arrays would be nice to hear. I understand the social resistance. I mean it will result in real work site maintainers have to do, and there will be code some developers are going to have to write. Something will break. I think if there is some significant advantage either in performance or memory then its something we should do. Or at least argue about for a bit. I'm going to go hide in the corner and stop trolling now. *** dopry ducks.