Being a developer can be really tough: you have to create and maintain (sometimes complex) structures and in the same time you have to stick to shorter deadlines.
Some developers think that the main aim of their job is to produce code which works. I’d say it’s the easy part of our work: the other difficult part is to build applications you can scale easily without passing hours in refactoring.
Object oriented programming can help you to reach this goal.
What means object oriented programming ? Putting objects everywhere in your application is far from enough to have what I call a well coded object oriented application. An application you can maintain and scale easily. You need to learn how to use objects properly.
Years after years I collected many resources on the subject which can help you to master the object oriented programming concepts. I list in this article the most useful ones, at least in order to learn the basics or to grow your knowledge in this topic.
However you can read all of those resources without really know how to use those concepts in practice (and even without really understand them). You have only one solution in order to mastering object oriented concepts: practice, practice and practice.
Create an object oriented side project, play with your new knowledge in some quick experimentations. Being a good developer comes with experience and practice, not only in reading theoretical articles.
Another good way to understand object oriented paradigm is to install a PHP framework and look at its structure. I put links to the most famous PHP frameworks at the end of this article as well.
If I had to choose only two resources for learning object oriented PHP, I’d choose those:
This book is nearly perfect for learning object oriented development in PHP. It is clear, easy to read and full of examples.
The first part is about the difference between procedural and object oriented development and the second about the most famous design pattern and why they are so useful in practical situations.
This project gathers the most useful and known design patterns in PHP. Very useful for a quick look when you think you can use those structures for a project. It includes examples, UML schemas and a quick description for each pattern.
If you don’t know anything about object and your knowledge is limited to procedural PHP, those first articles will be useful for you.
If you know what is an instance, an object or a class but you don’t know how to use them and why, you should read this section.
Following some articles from culttt.com I really like. It is easy to read, explained simply and clearly.
Sitepoint is as well a great community with a huge amount of interesting article for PHP web developers.
Those articles from different websites are very good as well:
If you know what are abstract classes, interface, magic methods, namespace but you don’t really now how to organise all those tools and when you should use them, those articles will explain you the big axes for designing object oriented architectures.
Following some articles on the OOP principles: how you should design your applications and what you shouldn’t do. Even if it’s not always possible to follow exactly those principles, it is always good to be close to them.
Finally an article very interesting about the possible alternative to the very well used MVC pattern:
There are a lot of videos about OOP on youtube. Those channels gather videos for beginner and more advanced developers.
As I said it can be very valuable to understand how a modern framework is structured.
Here some example:
This is not the end…
This article is made to evolve in the next months with more useful resources. Since then don’t hesitate to add your proper resources for learning or mastering OOP in the comment section!
And of course, don’t forget to practice !