SlideShare a Scribd company logo
OO PHP
Object Oriented PHP
OO PHP
 Object Oriented PHP




   Advantages over functional programming
• Systematic procedure for designing application by extracting nouns and verbs
   from specifications and using CRC (Classes, Responsibilities, Collaborators)
   Cards, then formation of a UML diagram.

• Much, much easier to maintain and add or change functionality

• Elimination of repetitious code - DRY (Don’t repeat yourself)

• Enables use of design patterns – super efficient algorithms that have evolved for
   accomplishing common OOP application functionality
Universal Modeling Language




(Horstmann, 2010)




                    Inheritance – “is a”
                    Aggregation – “has a”
                    Dependency – collaborating classes
                    Interface – contract for concrete implementation
Fundamental Concepts
•   Inheritance - extends
        override methods                              Object Oriented PHP for Beginners
                                                      http://www.killerphp.com/tutorials/object-oriented-php/
•   Setting Access Modifiers
    •   public, private, protected
    Use getter/setter methods and private instance
    variables (attributes)
•   Static Method or Attribute – belongs to the class,
    not the object instance (e.g., counters)
•   Scope resolution operator - error if cannot resolve
        Paamayim Nekudotayim*
    Referencing Parent Class – self::
    parent:: works with parent static or instance
    methods but not parent attributes, as well as
    $this-> refers to instance
    Constructors/Destructors – give a default value
    __construct($var=0){}
    Cloning Objects clone keyword and __clone()
                                                                                * Error Message in Hebrew
    method
                                                                                paam = One
•   Comparing Objects == vs. ===                                                ayim = Doubled
                                                                                nekudot = Dot
                                                                                ayim = Doubled
Object Oriented PHP Overview
Cloning vs. Object references
Design Patterns
• The Strategy Pattern defines a family
   of algorithms, encapsulates each       • The Iterator Pattern provides a way to
   one, and makes them                     access the elements of an aggregate
   interchangeable (polymorphism).         object sequentially without exposing its
   Strategy lets the algorithm vary        underlying representation.
   independently from the clients that   • The Adaptor Pattern changes the
   use it.                                 interface of one or more classes
• The Template Method pattern allows • The Decorator Pattern attaches
  a programmer to define the skeleton      additional responsibilities to an object
  of an algorithm in a superclass and      dynamically. Decorators provide a
  delegate specific steps to a subclass.   flexible alternative to subclassing.
  Subclasses can redefine certain steps • The Singleton Pattern ensures a class
  of an algorithm without changing the     only has one instance and provides a
  algorithm's structure.                   global point of access to it.
Project Overview

  • Photo gallery
      Thumbnail view
    • Full image view
    • Comments
    • Pagination
Project Overview
• Administration Back End
    Login
  • Create Admin users
  • Upload images
    Delete Images
  • Review/Delete Comments
Objects
                             User
                             Photograph
                             Comment

These will also serve as database tables. Usually when you have a database
                   table you have an object for that table.


                         • Database
                         • singleton pattern and allows for
                             adaptor pattern use if database format
                             changes, e.g., from MySQL to Oracle
                             Session
                             Additional Requirements
                         • Pagination
                         • Thumbnail generation
UML Diagram
Helpful Links
Object Oriented PHP for Beginners
http://www.killerphp.com/tutorials/object-oriented-php/
References
Freeman, Eric., Freeman, Elisabeth, Sierra, K., Bates, B. (2004). Head first
design patterns. Sebastpol, CA: O’Reilly Media, Inc.

Horstmann, C. (2010). Big Java 4th edition. (pp. 512-513). United States of
America: John Wiley & Sons, Inc.

Koffman, E. (2010). Data structures: abstraction and design using Java. (pp.
685-694). United States of America: John Wiley & Sons, Inc.

Lynda.com. (2009, March 25). PHP with MySQL beyond the basics.
Retrieved from http://www.lynda.com/tutorial/653

More Related Content

PDF
chubbyphp de/serialization
dominikzogg
 
PPTX
Object oriented programming
Saiful Islam Sany
 
PPTX
[OOP - Lec 01] Introduction to OOP
Muhammad Hammad Waseem
 
PPTX
Software enginering.group-no-11 (1)
riarana10
 
PDF
Reviewing OOP Design patterns
Olivier Bacs
 
PDF
Oop
志明 陳
 
PPT
Power of introspection
Joseph Jeffrey
 
PPTX
Object Oriented Programming Principles
Andrew Ferlitsch
 
chubbyphp de/serialization
dominikzogg
 
Object oriented programming
Saiful Islam Sany
 
[OOP - Lec 01] Introduction to OOP
Muhammad Hammad Waseem
 
Software enginering.group-no-11 (1)
riarana10
 
Reviewing OOP Design patterns
Olivier Bacs
 
Power of introspection
Joseph Jeffrey
 
Object Oriented Programming Principles
Andrew Ferlitsch
 

What's hot (10)

PPTX
cpp-2013 #9 STL Algorithms Part 1
Amazon Web Services
 
PPTX
Functional programming for the Advanced Beginner
Luis Atencio
 
PDF
Metaprogramming ruby
GeekNightHyderabad
 
PDF
How to Make Robust and Scalable Modeling Workbenches with Sirius - EclipseCon...
mporhel
 
PPTX
Lecture 1 oop
Tony Apreku
 
PPTX
Object Oriented Programming Languages
Mannu Khani
 
PPTX
operator overloading in c++
harman kaur
 
PPT
OOP Basics
CIB Egypt
 
PPT
Very Small Tutorial on Terrier 3.0 Retrieval Toolkit
Kavita Ganesan
 
PPTX
Object Oriented Programming in Java _lecture 1
Mahmoud Alfarra
 
cpp-2013 #9 STL Algorithms Part 1
Amazon Web Services
 
Functional programming for the Advanced Beginner
Luis Atencio
 
Metaprogramming ruby
GeekNightHyderabad
 
How to Make Robust and Scalable Modeling Workbenches with Sirius - EclipseCon...
mporhel
 
Lecture 1 oop
Tony Apreku
 
Object Oriented Programming Languages
Mannu Khani
 
operator overloading in c++
harman kaur
 
OOP Basics
CIB Egypt
 
Very Small Tutorial on Terrier 3.0 Retrieval Toolkit
Kavita Ganesan
 
Object Oriented Programming in Java _lecture 1
Mahmoud Alfarra
 
Ad

Similar to Object Oriented PHP Overview (20)

PDF
OOP in PHP
Tarek Mahmud Apu
 
PPT
Ooad ch 2
anujabeatrice2
 
PPTX
Oopsinphp
NithyaNithyav
 
PDF
Object oriented programming interview questions
Keet Sugathadasa
 
PDF
OOPs Concept
Mohammad Yousuf
 
PDF
Object Oriented Programming in PHP
Lorna Mitchell
 
PPT
Design Patterns and Usage
Mindfire Solutions
 
PDF
Oo aand d-overview
Saravana Suresh Saravanamuthu
 
PPTX
Concepts of oops
Sourabrata Mukherjee
 
PPTX
introofUML.pptx
RojaPogul1
 
PPTX
Intro to oop.pptx
UmerUmer25
 
PPT
Object Oriented Design
Aravinth NSP
 
PPT
Object Oriented Design
Sudarsun Santhiappan
 
PPT
Jump Start To Ooad And Design Patterns
Lalit Kale
 
PPS
Jump start to OOP, OOAD, and Design Pattern
Nishith Shukla
 
PPT
Ooad
gantib
 
PDF
Design patterns illustrated 010PHP
Herman Peeren
 
PPT
OOP
thinkphp
 
PPTX
SKILLWISE - OOPS CONCEPT
Skillwise Group
 
DOCX
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 
OOP in PHP
Tarek Mahmud Apu
 
Ooad ch 2
anujabeatrice2
 
Oopsinphp
NithyaNithyav
 
Object oriented programming interview questions
Keet Sugathadasa
 
OOPs Concept
Mohammad Yousuf
 
Object Oriented Programming in PHP
Lorna Mitchell
 
Design Patterns and Usage
Mindfire Solutions
 
Oo aand d-overview
Saravana Suresh Saravanamuthu
 
Concepts of oops
Sourabrata Mukherjee
 
introofUML.pptx
RojaPogul1
 
Intro to oop.pptx
UmerUmer25
 
Object Oriented Design
Aravinth NSP
 
Object Oriented Design
Sudarsun Santhiappan
 
Jump Start To Ooad And Design Patterns
Lalit Kale
 
Jump start to OOP, OOAD, and Design Pattern
Nishith Shukla
 
Ooad
gantib
 
Design patterns illustrated 010PHP
Herman Peeren
 
SKILLWISE - OOPS CONCEPT
Skillwise Group
 
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 
Ad

More from Larry Ball (6)

PDF
Swift
Larry Ball
 
PPTX
Angular js
Larry Ball
 
DOC
Comp325 v1 ww-ball-2-1
Larry Ball
 
PPTX
Php debugging
Larry Ball
 
KEY
EISA Considerations for Web Application Security
Larry Ball
 
KEY
jQueryUI
Larry Ball
 
Swift
Larry Ball
 
Angular js
Larry Ball
 
Comp325 v1 ww-ball-2-1
Larry Ball
 
Php debugging
Larry Ball
 
EISA Considerations for Web Application Security
Larry Ball
 
jQueryUI
Larry Ball
 

Recently uploaded (20)

PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Software Development Company | KodekX
KodekX
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PPTX
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
Software Development Methodologies in 2025
KodekX
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Doc9.....................................
SofiaCollazos
 
Software Development Company | KodekX
KodekX
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 

Object Oriented PHP Overview

  • 2. OO PHP Object Oriented PHP Advantages over functional programming • Systematic procedure for designing application by extracting nouns and verbs from specifications and using CRC (Classes, Responsibilities, Collaborators) Cards, then formation of a UML diagram. • Much, much easier to maintain and add or change functionality • Elimination of repetitious code - DRY (Don’t repeat yourself) • Enables use of design patterns – super efficient algorithms that have evolved for accomplishing common OOP application functionality
  • 3. Universal Modeling Language (Horstmann, 2010) Inheritance – “is a” Aggregation – “has a” Dependency – collaborating classes Interface – contract for concrete implementation
  • 4. Fundamental Concepts • Inheritance - extends override methods Object Oriented PHP for Beginners http://www.killerphp.com/tutorials/object-oriented-php/ • Setting Access Modifiers • public, private, protected Use getter/setter methods and private instance variables (attributes) • Static Method or Attribute – belongs to the class, not the object instance (e.g., counters) • Scope resolution operator - error if cannot resolve Paamayim Nekudotayim* Referencing Parent Class – self:: parent:: works with parent static or instance methods but not parent attributes, as well as $this-> refers to instance Constructors/Destructors – give a default value __construct($var=0){} Cloning Objects clone keyword and __clone() * Error Message in Hebrew method paam = One • Comparing Objects == vs. === ayim = Doubled nekudot = Dot ayim = Doubled
  • 6. Cloning vs. Object references
  • 7. Design Patterns • The Strategy Pattern defines a family of algorithms, encapsulates each • The Iterator Pattern provides a way to one, and makes them access the elements of an aggregate interchangeable (polymorphism). object sequentially without exposing its Strategy lets the algorithm vary underlying representation. independently from the clients that • The Adaptor Pattern changes the use it. interface of one or more classes • The Template Method pattern allows • The Decorator Pattern attaches a programmer to define the skeleton additional responsibilities to an object of an algorithm in a superclass and dynamically. Decorators provide a delegate specific steps to a subclass. flexible alternative to subclassing. Subclasses can redefine certain steps • The Singleton Pattern ensures a class of an algorithm without changing the only has one instance and provides a algorithm's structure. global point of access to it.
  • 8. Project Overview • Photo gallery Thumbnail view • Full image view • Comments • Pagination
  • 9. Project Overview • Administration Back End Login • Create Admin users • Upload images Delete Images • Review/Delete Comments
  • 10. Objects User Photograph Comment These will also serve as database tables. Usually when you have a database table you have an object for that table. • Database • singleton pattern and allows for adaptor pattern use if database format changes, e.g., from MySQL to Oracle Session Additional Requirements • Pagination • Thumbnail generation
  • 12. Helpful Links Object Oriented PHP for Beginners http://www.killerphp.com/tutorials/object-oriented-php/
  • 13. References Freeman, Eric., Freeman, Elisabeth, Sierra, K., Bates, B. (2004). Head first design patterns. Sebastpol, CA: O’Reilly Media, Inc. Horstmann, C. (2010). Big Java 4th edition. (pp. 512-513). United States of America: John Wiley & Sons, Inc. Koffman, E. (2010). Data structures: abstraction and design using Java. (pp. 685-694). United States of America: John Wiley & Sons, Inc. Lynda.com. (2009, March 25). PHP with MySQL beyond the basics. Retrieved from http://www.lynda.com/tutorial/653