Mar 29 at 5:25pm, Stephen Craton wrote: > I used OO in my chat script (can be found at http://php.melchior.us) but > it really seemed like a waste since it was such a small basic script. I > never really find myself re-needing code except for database > connectivity and calling the database and stuff like that.
If you take away your class statements, I'd wager that this looks a lot like it would had you just done it without OOP. It's a design and organization issue. What you have probably works, but there is so much more you could do if you spent your time designing objects in the proper way. Your database connection object is a more logical start... I think a chat app could easily be something more than just 'functional' if you start thinking about the tangible concepts you'd have in some kind of chat application-- users, chat sessions, messages. Then later say you want to add support for other types of "events".. then you think, hey, an event is just a different type of message, just extend the message object. When you've got a bunch of disorganized functions that work in specialized ways, you are adding on or reworking huge sections of code every time you want to add or change something. With well designed objects, the worst case scenario is you write a new object. I think there is a bit of what I consider an efficiency myth in regards to OOP in PHP. Most agree that the OO implementation in PHP is not robust. However, most people that rely on this assertion do not usually understand leveraging OO and also most do not write excellent non-OO code. :) If nothing else, getting a solid handle on the benefits of OOP can only make your code better, even if you choose not to use it in every situation (which most would suggest against in PHP, anyway). There IS something to OOP! Unfortunately, it's difficult to learn through examples of car stereo panels or different types of fruit or trees (though they do make perfect sense in hindsight). -- Kelly Hallman // Ultrafancy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php