From: Arlo L. <ar...@ar...> - 2009-06-13 06:31:59
|
Hi folks, Thanks for your feedback on this question! In particular... Rich wrote: > I would write it such that the getFoo() could accept multiple IDs, > across the board. This is the direction I've taken and it seems to be going well. For example, if I have a Orders class then it will include a getOrders method that can take a list of IDs and return a result set. And I've made getOrders a static method so that I can call it any time without having to instantiate an orders object. There's just one thing that bothers me about this. I can see the value of instantiating an object if I want to do a lot of work with it -- like if I have a multi-page order form that incrementally collects data and uses methods like calculateShipping and calculateTaxes along the way. But if I just want to view a list of orders, and I just call the static getOrders method, then I might as well be calling an ordinary function. It's still helpful to have all the functions relating to orders in one place, but is it weird to use the same Orders class in two fundamentally different ways? I guess what I'm saying is that classes have been useful throughout the site, but objects have only been useful in a few places. Kenneth wrote: > It's far more efficient to issues smart and efficient queries that > return associative arrays, and then have classes that know what to do > with those arrays. Can you elaborate on that? I think I agree but I wonder where you would put those SQL queries. So far I've been able to put all of my queries inside my classes without any special effort, and I'm liking that level of abstraction from the database. The classes are performing the queries and giving back arrays to the main page code. Matt wrote: > It appears your objects are just representations of data tables? > In our system we use a base class row.inc that handles a lot of the data > access and base functionality all classes need. > All other objects extend this class. I'm doing a similar thing with a Base class that provides some common functionality to all the other classes. For example, it can save and retrieve data from a session for that multi-page order form I mentioned above. I'm really digging the inheritance capabilities ... adding a new feature to the Base class makes it instantly available throughout the site. Wilfried wrote: > I personally don't spend tons of time going out of my way to make my > code all OOP'ed up just for the sake of OOP. For some things, OOP just > isn't the right axe. Agreed, but I'm already seeing some benefits with this project. I'll be able to share a lot more code between the public site and the admin interface, for example. Larry wrote: > Not only is it a good history lesson, this article is also spot-on about the > challenges of OO software and relational databases: > > http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx My goodness! Well, I'm relieved to hear that I'm not the only one who's feeling a little mixed up about this. Cheers, -Arlo _______________________________ Arlo Leach 773.769.6106 http://arlomedia.com |