Possible duplicate:
OOP versus functional programming and procedural
Recently, I got acquainted with the OO approach, so far I have written PHP using functions.
Now, to be honest, I really don't understand: When I use the idea of “Function”, I just include a file with a name, for example, functions.php, which has all the functions that I need, including vars, and when I need to use this snippet of code, I just call it and set vars or leave it empty if there are default values of vars.
Now, as far as I understand OO, instead of writing many functions without a “category”, I just collect them in a “class” (for example, all functions for working with db will be under the “db” 'class) - and instead, to give them vars, I declare these vars in advance in the class.
So it looks like I'm basically doing the same thing. I know that Vars are not global in OOP, and they are for each instance, which is suitable for creating more understandable code, but in addition, I can not feel the big difference in work:
$html = new html(); $html->src='http://stackoverflow.com'; $html->desc='Great place to learn & share knowledge'; $html->link();
-
html_link('http://stackoverflow.com','Great place to learn & share knowledge');
I agree that this may be more readable for those who did not write this code, but cannot see the big advantages that everyone is talking about: reuse, organization, speedup, etc.
Share your thoughts and maybe I will understand how I can benefit from OOP :)
Thanks in advance, Ik.