Skip to content
loading...

re: OOP practice with a standard project in PHP. VIEW POST

FULL DISCUSSION
 

This video was my intro to SOLID OOP and all the principles behind it:

If you're more into text, this tutorial did a good job of explaining stuff as well, albeit a bit old.

I highly recommend doing a small intro to OOP (tutorial or video) to roughly understand the fundamental structure (using classes, how to reference $this, dependency injection). Then once you've got that under your belt, try working with an ultra-simple OOP project. I picked up this one, and it helped break down the responsibilities of all the classes + methods.

I'd also recommend learning a framework like Laravel. It's primarily with OOP, and although it does some more complex stuff (interfaces, traits, etc) -- it'll force you to work within the paradigm. Check out the PHP section of Laracasts for guides to PHP basics, Jeffrey Way does a great job of walking you through it.

Don't worry if you get lost with all the "Liskov" principles or whatever. At the end of the day, OOP is class-orientated coding (as opposed to procedural or functional). If you're using classes, your 80% of the way there. The rest will come with practice. It's when you refactor your code, or reflect on it, that you'll start to apply the principles. You'll notice you repeating methods across multiple classes (leading to interfaces, traits, or extended classes), or you'll have issues with classes/methods becoming too complex (inside out principle). As you code OOP more you'll grasp it more.

 

Thanks for your comment.
I know the basics of design pattern and design principle. But I can not apply those in my own code. I will try your video. It would be better, If I got a real life video of a project applying those. I am searching it.

code of conduct - report abuse