SlideShare a Scribd company logo
1 of 13
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
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

What's hot

cpp-2013 #9 STL Algorithms Part 1
cpp-2013 #9 STL Algorithms Part 1cpp-2013 #9 STL Algorithms Part 1
cpp-2013 #9 STL Algorithms Part 1
Amazon Web Services
 

What's hot (10)

cpp-2013 #9 STL Algorithms Part 1
cpp-2013 #9 STL Algorithms Part 1cpp-2013 #9 STL Algorithms Part 1
cpp-2013 #9 STL Algorithms Part 1
 
Functional programming for the Advanced Beginner
Functional programming for the Advanced BeginnerFunctional programming for the Advanced Beginner
Functional programming for the Advanced Beginner
 
Metaprogramming ruby
Metaprogramming rubyMetaprogramming ruby
Metaprogramming ruby
 
How to Make Robust and Scalable Modeling Workbenches with Sirius - EclipseCon...
How to Make Robust and Scalable Modeling Workbenches with Sirius - EclipseCon...How to Make Robust and Scalable Modeling Workbenches with Sirius - EclipseCon...
How to Make Robust and Scalable Modeling Workbenches with Sirius - EclipseCon...
 
Lecture 1 oop
Lecture 1 oopLecture 1 oop
Lecture 1 oop
 
Object Oriented Programming Languages
Object Oriented Programming LanguagesObject Oriented Programming Languages
Object Oriented Programming Languages
 
operator overloading in c++
operator overloading in c++operator overloading in c++
operator overloading in c++
 
OOP Basics
OOP BasicsOOP Basics
OOP Basics
 
Very Small Tutorial on Terrier 3.0 Retrieval Toolkit
Very Small Tutorial on Terrier 3.0 Retrieval ToolkitVery Small Tutorial on Terrier 3.0 Retrieval Toolkit
Very Small Tutorial on Terrier 3.0 Retrieval Toolkit
 
Object Oriented Programming in Java _lecture 1
Object Oriented Programming in Java _lecture 1Object Oriented Programming in Java _lecture 1
Object Oriented Programming in Java _lecture 1
 

Similar to Object Oriented PHP Overview

Design patterns
Design patternsDesign patterns
Design patterns
Alok Guha
 
Python Programming - VI. Classes and Objects
Python Programming - VI. Classes and ObjectsPython Programming - VI. Classes and Objects
Python Programming - VI. Classes and Objects
Ranel Padon
 
Code reviews
Code reviewsCode reviews
Code reviews
Roger Xia
 
Code reviews
Code reviewsCode reviews
Code reviews
Roger Xia
 

Similar to Object Oriented PHP Overview (20)

Design p atterns
Design p atternsDesign p atterns
Design p atterns
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Introduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptIntroduction to Design Patterns in Javascript
Introduction to Design Patterns in Javascript
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
 
Python Programming - VI. Classes and Objects
Python Programming - VI. Classes and ObjectsPython Programming - VI. Classes and Objects
Python Programming - VI. Classes and Objects
 
Design patterns through refactoring
Design patterns through refactoringDesign patterns through refactoring
Design patterns through refactoring
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptx
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Software design with Domain-driven design
Software design with Domain-driven design Software design with Domain-driven design
Software design with Domain-driven design
 
Code reviews
Code reviewsCode reviews
Code reviews
 
dmBridge & dmMonocle
dmBridge & dmMonocledmBridge & dmMonocle
dmBridge & dmMonocle
 
Code reviews
Code reviewsCode reviews
Code reviews
 
AngularJS
AngularJSAngularJS
AngularJS
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their application
 
Complete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept itComplete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept it
 

More from Larry Ball (6)

Swift
SwiftSwift
Swift
 
Angular js
Angular jsAngular js
Angular js
 
Comp325 v1 ww-ball-2-1
Comp325 v1 ww-ball-2-1Comp325 v1 ww-ball-2-1
Comp325 v1 ww-ball-2-1
 
Php debugging
Php debuggingPhp debugging
Php debugging
 
EISA Considerations for Web Application Security
EISA Considerations for Web Application SecurityEISA Considerations for Web Application Security
EISA Considerations for Web Application Security
 
jQueryUI
 jQueryUI jQueryUI
jQueryUI
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

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
  • 5.
  • 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