Page 1 of 1

php OO question

Posted: Thu Dec 09, 2004 5:51 pm
by cto1mac
Is there really any gains to changing my site to an Object-oriented code? I understand that it could streamline alot of the insert and select portions of the site by accessing the various methods, but is there any security or performance gains to be had??

Thanks

Posted: Thu Dec 09, 2004 6:14 pm
by kettle_drum
Well security and perfomance gains tend to be achieved by good code and understanding what is going on - it therefore doesnt matter if you use OO or not if your code is bad. If your not used to OO then at first it may make your code worse as your not an expert at it, but after time it should be just as fast - if not faster, depending on who you ask.

It really depends on what views you have on the subject to say if your code will be better in OO, give it a go and see what you think of the style and ease/hardness or doing it and then make your own mind up. If your code is fast and secure in procedural, then it should be fast and secure in objects.

I would personally advise to writting in OO as i find it easier and gives all your code a solid uniform structure. If you write good abstract classes then the speed that you can gain is when developing new projects as you can just include the classes into that project.

Posted: Thu Dec 09, 2004 6:35 pm
by cto1mac
So, basically the best approach is broad-based classes with uniform methods to them. So that you can include them into projects so that your overall development time is less. I like it. Do you have any good places for full tutorials? I have managed to get some OO working but, I am sure I am not using it to anywhere near its full capabilities.

Posted: Thu Dec 09, 2004 7:36 pm
by McGruff
http://www.phppatterns.com
http://www.sitepoint.com/forums/showthread.php?t=78687

Learn how to use a unit testing framework such as SimpleTest as soon as possible. It might look like extra work but trust me, it brings a whole range of benefits including better designed, more robust classes and reduced time overall since testing almost eliminates lengthy debugging sessions. I put this off for a long time (there's so much to learn about) and I was kicking myself when I finally got round to testing. It's no accident that the term "test-infected" was coined. You will be.

It'll take a year or two to learn how to usefully encapsulate. En route you'll tear up all your work and start again several times but each time you'll be learning a little bit more. It takes quite a bit of experience to work out where to draw the lines of demarcation intelligently.

First, forget all that stuff about nouns and verbs. Move quickly on if someone starts talking about cars or bicycles. The secret is to have lean & mean classes which do just one thing.

Posted: Thu Dec 09, 2004 8:35 pm
by cto1mac
Please, I already acknowledge that if I write 50K lines of code for a project by then end I will have discarded or found a way to streamline at least 25K of it. I just want to be the best damn php programmer I can. OO is the way to go and I know this. I just wanted to find a good starting point. Thanks.