SlideShare a Scribd company logo
 
The Current Situation Object-Oriented Introduction Basics, concepts, terminology & examples Object-Oriented Benefits Code re-use, portability, structure, meaning, control, separation of responsibility, time, reduce dependencies and more
Most scripts & tutorials all procedural or show bad understanding of OO PHP’s unique history Template language & PHP/FI 2.0 “ evolved” over time with OO features Good OO finally starting to emerge PHP5 released in 2004 Zend Framework Symfony Project
 
That was easy! Add “Object-Oriented PHP” to your resume!
It’s much more than just syntax –  It’s a mindset Object-Oriented programming gives  meaning  to your data Represents real-world objects when possible Where have we seen this before?
Semantic markup Think: <blockquote> for quotes, not indentation <address> for addresses, not <p> or <div> <cite> instead of <i> for citations Goal is to for code to  convey meaning
Create meaning and structure Separate responsibilities Reduce/Isolate dependencies Create common public interfaces Clear, self-documenting code
Code objects cannot  always  represent real-world objects Application flow Structure Delegation Separation of responsibilities How do we solve these problems? Design Patterns
Model-View-Controller (MVC) Active Record Data Mapper Adapter Registry Factory Observer
What OO programming is  not  – where many PHP projects go wrong
 
Decorator
What is User? A finder/utility class? No clear definition or purpose “ bob”  is  a User 1 instance = 1 user Properties of a user Functions of a user
The power of applying object-oriented design to your application
Objects add automatic clarity Stick to standards and naming conventions camelCase Zend Coding Standards Function naming as verbose as possible getPostBySlug($slug) findPostsWithTag($tagName)
 
 
 
Parent > Child relationship between objects Child extends Parent Child inherits all parent methods Child can override parent methods when required Changes can be reflected across your entire application with relative ease
 
Hides actual implementation Reduces or isolates dependencies to lower levels Reduces or eliminates extensive future changes in code base
Adding extra headers is a mess (CC, BCC) No built-in file attachment options Limited configuration options (Sendmail/SMTP) Very inefficient for large amounts of email
Custom Email() object Clear, descriptive syntax Unlimited configuration options  mail(), SMTP, database, external server, etc. File attachments can be easy with function
Did you notice the dependencies?
Remove the database dependencies by using a standard interface PDO provides one (bundled with PHP5) Use  dependency injection  to expose dependencies
Pass connection into constructor and store it as a class property Replace mysql_* functions with standard functions from PDO using connection
Database adapters are interchangeable
Interchangeable code components Standard interface Single dependency Separate “engine” from implementation
Different payment processors are a simple drop-in replacement
Objects should serve a single purpose Separate code into manageable chunks MVC – Good example Model – Database View – Display Controller – Request/Flow Resist temptation of globals everywhere “ global $var”, $_SESSION, $_REQUEST, etc
 
 
Building a Data Mapper with PHP5 and the Standard PHP Library Friday Oct. 10 @ 10:30am
www.php.net/php5 Full official PHP5 feature documentation Communities Sitepoint – sitepoint.com PHPit – phpit.com PHP|Architect – phparch.com Zend Developer Zone - devzone.zend.com
Vance Lucas, 23 Blog:  www.vancelucas.com Email:  [email_address] Making websites since age 12 Started learning PHP when PHP3 was new Oklahoma Baptist University – Shawee Bachelor of Business Administration Currently work at Back40 Design, Inc. www.back40design.com
 

More Related Content

PPTX
Object oriented programming
DOCX
Object oriented programming tutorial
PPTX
Principles and advantages of oop ppt
PPTX
Characteristics of OOPS
PPTX
Object Oriented Programming Principles
PPTX
Characteristics of oop
PPTX
Introduction to Object Oriented Programming
Object oriented programming
Object oriented programming tutorial
Principles and advantages of oop ppt
Characteristics of OOPS
Object Oriented Programming Principles
Characteristics of oop
Introduction to Object Oriented Programming

What's hot (20)

PDF
Object-oriented programming (OOP) with Complete understanding modules
PDF
Concepts of OOPs
PPT
Oop Presentation
PPTX
Object oriented programming
PPT
OOP programming
PPTX
Oop ppt
PPTX
Object Oriented Programming in Java _lecture 1
PDF
Introduction to object oriented programming
PPTX
Object Oriented Concept
PDF
PPT
Oops
PPT
2 Object Oriented Programming
PPTX
principle of oop’s in cpp
PPTX
Introduction to Object Oriented Programming
PPTX
01 introduction to oop and java
PPTX
OOP - Benefits and advantages of OOP
PPTX
Oo ps concepts in c++
PPTX
Object-Oriented concepts.pptx
Object-oriented programming (OOP) with Complete understanding modules
Concepts of OOPs
Oop Presentation
Object oriented programming
OOP programming
Oop ppt
Object Oriented Programming in Java _lecture 1
Introduction to object oriented programming
Object Oriented Concept
Oops
2 Object Oriented Programming
principle of oop’s in cpp
Introduction to Object Oriented Programming
01 introduction to oop and java
OOP - Benefits and advantages of OOP
Oo ps concepts in c++
Object-Oriented concepts.pptx
Ad

Similar to PHP - Procedural To Object-Oriented (20)

PPT
Php Frameworks
PPT
Demo
PPT
first pitch
PPT
PPT
sadasd
PPT
first pitch
PPT
latest slide
PPT
before upload
PPT
PPT
before upload
PPT
latest slide
PPT
latest slide
PPT
PPT
tiwari
PPT
latest slide
PPT
Test Nan
PPT
tiwari
PPT
Greenathan
PPT
Unit Test for ZF SlideShare Component
PPT
latest slide
Php Frameworks
Demo
first pitch
sadasd
first pitch
latest slide
before upload
before upload
latest slide
latest slide
tiwari
latest slide
Test Nan
tiwari
Greenathan
Unit Test for ZF SlideShare Component
latest slide
Ad

More from Vance Lucas (8)

PDF
How to Evaluate Your App Idea
PDF
How to Build a Tech Community
PDF
Bullet: The Functional PHP Micro-Framework
PDF
Stackbox CMS: Next-Generation Content Management
PDF
Cross-Platform Mobile Development with Titanium
PDF
Alloy HMVC PHP Framework
PPTX
Object Oriented Apologetics
PPT
Building Data Mapper PHP5
How to Evaluate Your App Idea
How to Build a Tech Community
Bullet: The Functional PHP Micro-Framework
Stackbox CMS: Next-Generation Content Management
Cross-Platform Mobile Development with Titanium
Alloy HMVC PHP Framework
Object Oriented Apologetics
Building Data Mapper PHP5

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Modernizing your data center with Dell and AMD
PPT
Teaching material agriculture food technology
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Chapter 2 Digital Image Fundamentals.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
KodekX | Application Modernization Development
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Empathic Computing: Creating Shared Understanding
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Modernizing your data center with Dell and AMD
Teaching material agriculture food technology
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Review of recent advances in non-invasive hemoglobin estimation
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Chapter 2 Digital Image Fundamentals.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
KodekX | Application Modernization Development
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Dropbox Q2 2025 Financial Results & Investor Presentation
Sensors and Actuators in IoT Systems using pdf
GamePlan Trading System Review: Professional Trader's Honest Take
Empathic Computing: Creating Shared Understanding
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

PHP - Procedural To Object-Oriented

  • 1.  
  • 2. The Current Situation Object-Oriented Introduction Basics, concepts, terminology & examples Object-Oriented Benefits Code re-use, portability, structure, meaning, control, separation of responsibility, time, reduce dependencies and more
  • 3. Most scripts & tutorials all procedural or show bad understanding of OO PHP’s unique history Template language & PHP/FI 2.0 “ evolved” over time with OO features Good OO finally starting to emerge PHP5 released in 2004 Zend Framework Symfony Project
  • 4.  
  • 5. That was easy! Add “Object-Oriented PHP” to your resume!
  • 6. It’s much more than just syntax – It’s a mindset Object-Oriented programming gives meaning to your data Represents real-world objects when possible Where have we seen this before?
  • 7. Semantic markup Think: <blockquote> for quotes, not indentation <address> for addresses, not <p> or <div> <cite> instead of <i> for citations Goal is to for code to convey meaning
  • 8. Create meaning and structure Separate responsibilities Reduce/Isolate dependencies Create common public interfaces Clear, self-documenting code
  • 9. Code objects cannot always represent real-world objects Application flow Structure Delegation Separation of responsibilities How do we solve these problems? Design Patterns
  • 10. Model-View-Controller (MVC) Active Record Data Mapper Adapter Registry Factory Observer
  • 11. What OO programming is not – where many PHP projects go wrong
  • 12.  
  • 14. What is User? A finder/utility class? No clear definition or purpose “ bob” is a User 1 instance = 1 user Properties of a user Functions of a user
  • 15. The power of applying object-oriented design to your application
  • 16. Objects add automatic clarity Stick to standards and naming conventions camelCase Zend Coding Standards Function naming as verbose as possible getPostBySlug($slug) findPostsWithTag($tagName)
  • 17.  
  • 18.  
  • 19.  
  • 20. Parent > Child relationship between objects Child extends Parent Child inherits all parent methods Child can override parent methods when required Changes can be reflected across your entire application with relative ease
  • 21.  
  • 22. Hides actual implementation Reduces or isolates dependencies to lower levels Reduces or eliminates extensive future changes in code base
  • 23. Adding extra headers is a mess (CC, BCC) No built-in file attachment options Limited configuration options (Sendmail/SMTP) Very inefficient for large amounts of email
  • 24. Custom Email() object Clear, descriptive syntax Unlimited configuration options mail(), SMTP, database, external server, etc. File attachments can be easy with function
  • 25. Did you notice the dependencies?
  • 26. Remove the database dependencies by using a standard interface PDO provides one (bundled with PHP5) Use dependency injection to expose dependencies
  • 27. Pass connection into constructor and store it as a class property Replace mysql_* functions with standard functions from PDO using connection
  • 28. Database adapters are interchangeable
  • 29. Interchangeable code components Standard interface Single dependency Separate “engine” from implementation
  • 30. Different payment processors are a simple drop-in replacement
  • 31. Objects should serve a single purpose Separate code into manageable chunks MVC – Good example Model – Database View – Display Controller – Request/Flow Resist temptation of globals everywhere “ global $var”, $_SESSION, $_REQUEST, etc
  • 32.  
  • 33.  
  • 34. Building a Data Mapper with PHP5 and the Standard PHP Library Friday Oct. 10 @ 10:30am
  • 35. www.php.net/php5 Full official PHP5 feature documentation Communities Sitepoint – sitepoint.com PHPit – phpit.com PHP|Architect – phparch.com Zend Developer Zone - devzone.zend.com
  • 36. Vance Lucas, 23 Blog: www.vancelucas.com Email: [email_address] Making websites since age 12 Started learning PHP when PHP3 was new Oklahoma Baptist University – Shawee Bachelor of Business Administration Currently work at Back40 Design, Inc. www.back40design.com
  • 37.