OO PHPObject Oriented PHP
OO PHP Object Oriented PHP   Advantages over functional programming• Systematic procedure for designing application by ext...
Universal Modeling Language(Horstmann, 2010)                    Inheritance – “is a”                    Aggregation – “has...
Fundamental Concepts•   Inheritance - extends        override methods                              Object Oriented PHP for...
Cloning vs. Object references
Design Patterns• The Strategy Pattern defines a family   of algorithms, encapsulates each       • The Iterator Pattern pro...
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/Delet...
Objects                             User                             Photograph                             CommentThese w...
UML Diagram
Helpful LinksObject Oriented PHP for Beginnershttp://www.killerphp.com/tutorials/object-oriented-php/
ReferencesFreeman, Eric., Freeman, Elisabeth, Sierra, K., Bates, B. (2004). Head firstdesign patterns. Sebastpol, CA: O’Re...
Object Oriented PHP Overview
Upcoming SlideShare
Loading in …5
×

Object Oriented PHP Overview

1,688 views
1,556 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,688
On SlideShare
0
From Embeds
0
Number of Embeds
36
Actions
Shares
0
Downloads
24
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Object Oriented PHP Overview

  1. 1. OO PHPObject Oriented PHP
  2. 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. 3. Universal Modeling Language(Horstmann, 2010) Inheritance – “is a” Aggregation – “has a” Dependency – collaborating classes Interface – contract for concrete implementation
  4. 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. 5. Cloning vs. Object references
  6. 6. 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 algorithms structure. global point of access to it.
  7. 7. Project Overview • Photo gallery Thumbnail view • Full image view • Comments • Pagination
  8. 8. Project Overview• Administration Back End Login • Create Admin users • Upload images Delete Images • Review/Delete Comments
  9. 9. Objects User Photograph CommentThese 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
  10. 10. UML Diagram
  11. 11. Helpful LinksObject Oriented PHP for Beginnershttp://www.killerphp.com/tutorials/object-oriented-php/
  12. 12. ReferencesFreeman, Eric., Freeman, Elisabeth, Sierra, K., Bates, B. (2004). Head firstdesign patterns. Sebastpol, CA: O’Reilly Media, Inc.Horstmann, C. (2010). Big Java 4th edition. (pp. 512-513). United States ofAmerica: 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

×