Page 1 of 1
OO vs. Procedural
Posted: Fri Jul 16, 2004 8:48 pm
by evilmonkey
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.
Posted: Fri Jul 16, 2004 8:51 pm
by feyd
I try to use OO for the most part. Although it takes a bit more time for initial set up of 1 instance, the general level the implementations are is great for reuse..
Posted: Fri Jul 16, 2004 11:03 pm
by infolock
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.
Posted: Fri Jul 16, 2004 11:08 pm
by Weirdan
OO is the only way to go for large projects (>~1M lines of code) imo.
Posted: Fri Jul 16, 2004 11:24 pm
by feyd
I have to absolutely, hands-down, agree with Weirdan on that. There no faster way to get into trouble in a large project than to not use classes/objects and OOP.. unless you're a very gifted professional
Posted: Fri Jul 16, 2004 11:51 pm
by Weirdan
this tiny shell script can help you to decide whether you need to switch or don't:
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
Run it in the directory under which all your php files located and it will tell you

Posted: Fri Jul 16, 2004 11:52 pm
by feyd
heheh nice one Weirdan..
CONGRATS ON 1000 POSTS!
Posted: Sat Jul 17, 2004 12:04 am
by Weirdan
feyd wrote:heheh nice one Weirdan..
Mine told me I needed some books
feyd wrote:
CONGRATS ON 1000 POSTS!
Thanks

Posted: Sat Jul 17, 2004 9:04 am
by evilmonkey
Thanks for the input, looks like I have to learn OOP in PHP. Got suggestions on resources?
Thanks!
Posted: Sun Jul 18, 2004 1:27 pm
by nigma
Posted: Sun Jul 18, 2004 3:18 pm
by evilmonkey
Thanks Nigma, I'll read those.
