4. The Anatomy of a Class
Learning Object-Oriented Programming this time around allowed me to grasp how important the static keyword is so I want to point it out. The ability to be able to share allocated memory between objects can come in very handy when creating low level attributes and methods. Think about static properties as that share the same value. A good example of this is a franchise business. Lets use McDonalds for this example. Consider the name of their burgers the attributes and the burgers themselves the value. Although McDonalds has many physical locations, the name of the burgers remain the same as well as the ingredients used to make the burgers. If the headquarters changes the receipe of the burgers, they must all change the receipe of the burgers. They all share the same receipe or value.
Accessor are vital for any class which deals which data.HINT HINT Accessors allow you to filter data in order to keep a consistant format across your system. USE THEM.
Public Methods & Private Methods
In order to implement encapsulation, we must keep our properties as private as possible. We will use Public Methods aka Public Interfaces to allow other objects access to our private methods. Keep in mind, Private Methods aka Private Implementations are meant to be called within a Public Method or another private method.
Download Lesson Notes