OO vs. Procedural
Moderator: General Moderators
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
OO vs. Procedural
Hello. I've been coding in PHP for about 2 years now, doing mostly databasing. Up until now, I've been using strictly procedural approaches to my problems, and it worked fine. I'm now in a position where I have to develop a big project using PHP4's OO capabilities. I've read a lot of tutorials and sections of books on this topic, but now I want to hear from people. Which style do you use and why. Also, any tips for a coder migrating from procedural to OO are greatly appreciated.
OO is definately the way to go imo.. considering all the scripts you'll make in the future that can use this class' login functions, it's table/frame builds, loops, etc, you are going to find it not only to be a nicer way to keep all your functions in one file, but also that it will save you on time.
basically, if ur going to be reusing a lot of custom/redundant functions in more than one place, classes are the only way to go. otherwise, u'll just be wasting your time imo.
basically, if ur going to be reusing a lot of custom/redundant functions in more than one place, classes are the only way to go. otherwise, u'll just be wasting your time imo.
this tiny shell script can help you to decide whether you need to switch or don't:
Run it in the directory under which all your php files located and it will tell you 
Code: Select all
lines=`(find ./ -name *php -exec wc {} \;) | awk '{as=as+$1;}
END {print as}'`;
if ї $lines -gt 1000000 ]; then
echo \"e;You need to switch to OOP NOW! \"e;;
elif ї $lines -gt 100000 ]; then
echo \"e;Go buy some books on OOP, you'll need to swith soon! \"e;;
else
echo \"e;You can live without OOP... for some time ;)\"e;;
fi
Last edited by Weirdan on Thu Jul 14, 2005 9:32 am, edited 1 time in total.
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
basic tutorial on oop in php4
----------------------------------
part 1: http://www.onlamp.com/pub/a/php/2002/07 ... tions.html
part 2: http://www.onlamp.com/pub/a/php/2002/08 ... tions.html
----------------------------------
part 1: http://www.onlamp.com/pub/a/php/2002/07 ... tions.html
part 2: http://www.onlamp.com/pub/a/php/2002/08 ... tions.html
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada