OBJECT ORIENTED PROGRAMMING (OOP), understanding the theoretical concept
Object Oriented programming (OOP) is a programming model built on the notion of “…instantiated class as an instance of an object (or vice versa)”. Or, in clearer analogy, “…a child is an instance of a Parent.” Most classes have predefined properties (adjectives or attributions), methods or functions (verbs or actions of the class or object) that describe it and/or make it come alive. Most popular Languages in use today in the computer industry such as C++, Java, Python, Perl, Julia, Matlab, Kotlin, etc.) by default come shipped with predefined classes which any software developer can extend or create new instance of and make new ones away from the preexisting.
The following are some of the important perceptions backing practical Object Oriented Language which in practical effect applies to most modern day industrial software application development.
- Encapsulation: Simply put, encapsulation transpires, when a class has private control over its properties (adjectives, attributes) and methods/functions (verbs or actions). Its properties and methods/functions are only accessible/modified if the “public” access modifier is explicitly assigned before the property/method. Hence, the class unconditionally maintains its domain in the absence of this. For the record, php programming language recognizes three major access modifiers namely “public”, “private”, and “protected”. In the attached YouTube Video, I make full explanation with practical examples.
- Abstraction: This is the annex of Encapsulation. As programs grow, handling class properties/methods becomes tedious. Hence, Abstraction (initializing interfacing) of an Object where its methods can be overridden (method overriding of a parent class by a child class) becomes a very useful feature.
- Inheritance: This is one of the popular conceptualizations of an object oriented programming. The simplest explanation of this is the biological concept of genetics, where a child inherits traits from parent. In the like manner, inheritance occurs in PHP objects through the use of the keyword “extend”. The moment this is initialized with a class name, all the Parent properties/methods become immediately availed to the calling child class.
- Polymorphism: This infers “taking several forms”. For instance, creating a blend of classes for a collective task, or implementing a method/function for a parent/child class to use without altering the access of the original class that provides this access.
Take the next hour and half or so to study with the YouTube Video provided to grasp the theoretical and practical fundamentals of Object Oriented Programming with respect to PHP/SQL and lay the prerequisites for taking on other languages such a Python. Java, C, C++, C#.Net, Kotlin, Matlab, Julia etc.
Authored by: Engr. Oluwatobi (Tobi) Owoeye