object oriented php overview
DESCRIPTION
TRANSCRIPT
OO PHPOO PHPObject Oriented PHP
OO PHPOO PHPObject Oriented PHP
•Text
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
Universal Modeling Language
Inheritance – “is a”Aggregation – “has a”Dependency – collaborating classesInterface – contract for concrete implementation
(Horstmann, 2010)
Fundamental ConceptsFundamental ConceptsInheritance - extends
override methods
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() method
Comparing Objects == vs. ===
Object Oriented PHP for Beginners http://www.killerphp.com/tutorials/object-oriented-php/
* Error Message in Hebrewpaam = Oneayim = Doublednekudot = Dotayim = Doubled
Cloning vs. Object references
Design PatternsDesign PatternsThe Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable (polymorphism). Strategy lets the algorithm vary independently from the clients that use it.
The Template Method pattern allows a programmer to define the skeleton of an algorithm in a superclass and delegate specific steps to a subclass. Subclasses can redefine certain steps of an algorithm without changing the algorithm's structure.
The Iterator Pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.The Adaptor Pattern changes the interface of one or more classesThe Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing.The Singleton Pattern ensures a class only has one instance and provides a global point of access to it.
Project OverviewProject Overview
Photo gallery
Thumbnail view
Full image view
Comments
Pagination
Project OverviewProject OverviewAdministration Back End
Login
Create Admin users
Upload images
Delete Images
Review/Delete Comments
ObjectsObjectsUser
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
UML Diagram
Helpful LinksHelpful LinksObject Oriented PHP for Beginners http://www.killerphp.com/tutorials/object-oriented-php/
ReferencesReferencesFreeman, 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