SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

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