beginning oop in php

47
Beginning OOP in PHP OpenWest - May 7, 2015 David Stockton

Upload: david-stockton

Post on 17-Jul-2015

145 views

Category:

Technology


1 download

TRANSCRIPT

Beginning OOP in PHP

OpenWest - May 7, 2015 David Stockton

David Stockton VP of Technology, i3logix Denver, CO

Coding in PHP for over 17 years Organizer of the Front Range PHP User Group for 5 years Board of Directors, Front Range Web Developer Assoc.

@dstockto http://davidstockton.com http://tddftw.com https://www.youtube.com/user/dstockto/videos

#phpmentoring #phpstudygroup

What we’ll talk about• Classes

• Objects

• Interfaces

• Inheritance

• Methods

• Properties

• Visibility Modifiers

• Static

• Constructors

Why bother with OOP?

Lack of AbstractionProblems with Procedural Code

Why bother with OOP?

Data stores as structure

Problems with Procedural Code

Why bother with OOP?

Functions are global and not related to structures

Problems with Procedural Code

What is a class?

A blueprint

Simple Class

Defines stateWhat does a class do?

What are properties?

Information / Data on an object

What does a class do?

Defines behavior

What are methods?

Behaviors on a class

What’s an object?

An instance of a class

Constructor

One of PHP’s “magic” methods

__construct

Used to initialize the properties of the object

Visibility ModifiersPublic

Protected

Private

PublicMethod or property is available to anything

From anywhere

Protected

Property or method available within the class or class’s inheritance structure (both ways)

Private

Method or property only available within the object

Inheritance

“is a”

“is a”

“is a”

“is a”

“is a”

“is a”

“is a”

“is a”

“is a”

“is a”

“is a”

“is a”

“is a”

What is encapsulation?

What is an interface?

Commonly named functionality

What is an interface?

A contract between caller and callee

Why are interfaces important?

Allows common language and API for different classes

Static

Method or class available at Class level, no object needed

Changes affect all instances of the class

Abstract Classes

Provides functionality to child classes

Cannot be instantiated

Questions?

Plea

se rate this talk

https://joind.in/13950