Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Moving from procedural to OOP?

How difficult is it to move from procedural to OOP? I've always coded in proc, and never even touched OOP. Are there any preparation steps I should take? Any pitfalls to look out for?
aint my sig design skills sick?
shouldn't be too difficult if you're good at procedural.

in the simplest cases you will be changing from
PHP Code

<?php 
do_something
($resource, $paramater) 
to
PHP Code

<?php 
$resource
->do_something($paramater); 
/* No comment */
(Jul 5, 2018 12:57 AM).eXe Wrote:  How difficult is it to move from procedural to OOP? I've always coded in proc, and never even touched OOP. Are there any preparation steps I should take? Any pitfalls to look out for?

There must be tons of tutorials and books out there since PHP became OO. e.g. https :// code.tutsplus.com/ tutorials/object-oriented-php-for-beginners--net-12762
(Jul 6, 2018 07:02 AM)d4rkc4st Wrote:  There must be tons of tutorials and books out there since PHP became OO. e.g. https :// code.tutsplus.com/ tutorials/object-oriented-php-for-beginners--net-12762

Using PHP in an OOP setting isn't what I asked, it was the best way to move from only using procedural to OOP.
aint my sig design skills sick?
Look up the S.O.L.I.D design principles for OOP and that should steer you in the right direction.
(Jul 6, 2018 07:11 AM).eXe Wrote:  Using PHP in an OOP setting isn't what I asked, it was the best way to move from only using procedural to OOP.

Just make sole purposes functions for everything and then call it a class, pretty much what OOP is lol.
Hi,

i wrote a little example for you: gist.github.com/mariusgerum/a32e803e1022956759c4764dad74dec9 (sorry i can't post real links yet, so just copy&paste it into your browser).

As you can see the logic resides in one single place where you actually need it instead of spreading that shit all over your entire codebase.
🡑🡑🡑


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by OneandonlySunny™Apr 22, 2020 10:54 PM 9 205 Apr 22, 2020 10:54 PM
Last Post: OneandonlySunny™
[PHP] by bull daemonDec 10, 2018 04:23 AM 4 185 Dec 10, 2018 04:23 AM
Last Post: northerncrisp
[PHP] by DarkWapOneJan 21, 2018 11:48 AM 2 143 Jan 21, 2018 11:48 AM
Last Post: RumbleFrog