SlideShare une entreprise Scribd 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
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

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Dernier

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Dernier (20)

Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 

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