What is Object-Oriented Programming?. Objects – Variables and Logic inside "Objects", not...

6
What is Object-Oriented Programming?

Transcript of What is Object-Oriented Programming?. Objects – Variables and Logic inside "Objects", not...

Page 1: What is Object-Oriented Programming?. Objects – Variables and Logic inside "Objects", not standalone code – Objects contain related variables and functions.

What is Object-Oriented Programming?

Page 2: What is Object-Oriented Programming?. Objects – Variables and Logic inside "Objects", not standalone code – Objects contain related variables and functions.

• Objects– Variables and Logic inside "Objects", not standalone code– Objects contain related variables and functions

• Key Concepts– Encapsulation– Inheritance– Polymorphism

Page 3: What is Object-Oriented Programming?. Objects – Variables and Logic inside "Objects", not standalone code – Objects contain related variables and functions.

• Key Terminology– Functions defined in an Object are called "Methods"– Variables defined within an Object (not inside functions)

are called "Properties" of the Object– An Object is built (or instantiated) from a "class" that defines

what is contained in an Object– A class can inherit properties and methods from another class – An abstract class can be inherited by another class, but not instantiated – An interface can contain constants and method definitions that

can be implemented by other classes

Page 4: What is Object-Oriented Programming?. Objects – Variables and Logic inside "Objects", not standalone code – Objects contain related variables and functions.

• A Simpler Way To Think About Object-Oriented Programming

"Objects are defined by a meaningful name that keeps related functions

and variables together in one place"

• Example:– A Payroll object would contain a variable holding a check number and a

function that would calculate the withholding tax on a paycheck– Payroll>checkNumber – Payroll>calcWithholdingTax()

Page 5: What is Object-Oriented Programming?. Objects – Variables and Logic inside "Objects", not standalone code – Objects contain related variables and functions.

• What's Missing in PHP compared to other OOP Languages?– PHP's data weakly typed– PHP's objects are not explicitly typed

• No object detection (polymorphism problem)– No way to instantiate an object of one type into an object of

a supertype

– Functions do not enforce a particular data type that must be returned

Page 6: What is Object-Oriented Programming?. Objects – Variables and Logic inside "Objects", not standalone code – Objects contain related variables and functions.

• End of Presentation