Object Oriented PHP (Lesson 2: Objects & Static Methods)
Clean Code Studio
Posted on August 23, 2021
An object is the implementation of a class. As discussed in lesson 1, a class is simply a blue print that outlines something. An object is the actual thing that specifies the specific details.
Objects: Implementation of a Class
- Conceptualize a band
- A band has a name
- A band has members
- A band can add a member
- A band has music
- A band can play music
Static Methods:
- Are callable from the class level (You don't need to create an instance of the class to call it)
- Are considered "global to the class namespace"
- I recommend watching the tutorial linked above to better understand static methods - the screencast does a thorough job explaining static methods.
Objects
In object-oriented programming (OOP), objects are the things you think about first in designing a program and they are also the units of code that are eventually derived from the process. ... Each object is an instance of a particular class or subclass with the class's own methods or procedures and data variables.
Static Methods
In object-oriented programming (OOP) the methods that belong to a class definition are called static methods. (Sometimes they are called class methods, but this is confusing.) A static method is part of a class definition, but is not part of the objects it creates. Important: A program can execute a static method without first creating an object!
Posted on August 23, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.