Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
There are a number of very practical reasons for using object-oriented programming, and not just because it looks good on paper. The short reason? Object-oriented programming organizes projects into consistent, manageable pieces. As a developer, I've come to really appreciate well-organized code, as it saves time and money. In comparison, procedural programming is a set of step-by-step instructions that the computer must follow. A procedural program can consist of a series of conditions, and function calls for logic, but the end result is very linear.
Meaning, program execution is like a straight line, rigid and inflexible. There's nothing wrong with procedural programming, and for small projects, it can be a good solution. The problem comes when you scale up. You may find yourself defining arrays with long descriptive keys, or passing large numbers of global variables between scripts, or even searching for a non-fatal bug across a dozen squares with thousands of lines of code with little indication of which component is at fault. Object-oriented programming introduces structure intended to avoid the scaling and maintenance issues.
Throughout this course, I am going to explore a number of features of object-oriented programming, including abstraction, which defines data and program structures using a representation of meaning, while hiding the implementation itself. This allows for the use of human readable terminology to be used as part of the software. Next is encapsulation, which exposes functionality while restricting access to low-level components and data. You can also introduce a hierarchy where properties and behavior from pre-existing classes are inherited, which allows for incremental development.
Another feature is modularity, where functionality is broken into modules that accomplish one task, and contain everything necessary to complete said task. Instead of trying to deal with one large problem, a number of smaller sub-problems work together to solve the bigger problem. And finally, polymorphism, which is the ability to interact with classes in the same way without having to know exactly which class they are. By using object-oriented programming, you can build small components that can be easily maintained and expanded upon without messing up the entire program. That way, you can create and test the program in small pieces, rather than trying to deal with huge, messy code.
But has PHP always supported this kind of object-oriented programming?
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101713 Viewers
61 Video lessons · 88469 Viewers
71 Video lessons · 72295 Viewers
56 Video lessons · 104015 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.