• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
PHP - Procedural To Object-Oriented

PHP - Procedural To Object-Oriented



Learn the power of object-oriented programming in PHP5 and the many benefits it offers over the more traditional PHP procedural programming style. This session will include a light introduction to ...

Learn the power of object-oriented programming in PHP5 and the many benefits it offers over the more traditional PHP procedural programming style. This session will include a light introduction to object-oriented concepts and will provide real-world concrete examples of the benefits it can offer you and the PHP projects you work on.



Total Views
Views on SlideShare
Embed Views



9 Embeds 203

http://www.slideshare.net 79
http://oop.li 50
http://www.vancelucas.com 39
http://blog.gabrieleromanato.com 12
http://www.santanu.in 11
http://onwebdev.blogspot.com 4
http://paper.li 4
http://snitedu.com 3
http://www.linkedin.com 1



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.


15 of 5 previous next Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • Good presentation
    Are you sure you want to
    Your message goes here
  • @Alex -

    Your comment doesn’t really have anything to do with OO code vs. procedural code. Not all OO code is good, just like not all procedural code is good. Smarty is well known for being poorly designed and using too many resources. I had the exact same problem on a recent project I walked into where a single request was using over 14MB of memory, mostly due to Smarty.

    Writing good OO code is more about changing your behavior and thinking about writing code than anything else. Good OO code will show in its flexibility and maintainability. There are always tradeoffs that are made, and although an OO style does tend to produce more actual code overall, the implementation use of the code is often more concise and readable to the end user. It’s not about enterprise vs. small projects - good OO code can be used anywhere with minimal performance impact.

    As for the security holes, the example code is just simple demonstrations of specific differences in organizational styles, nothing more. None of it is production code.
    Are you sure you want to
    Your message goes here
  • This is utter rubbish, I'm sorry but I code php in a procedural way and it is alot faster and more scalable than an OOP approach. Just as a quick example I recently converted (for a client) a smarty OOP approach to a procedural approach. The smarty was averaging about 6 seconds load time for a page and killing the CPU of the server - the OOP was also very long and cumbersome and not easy to identify when working on someone else's code... I took it to procedural and shaved 5 seconds from the load time, 98% off the CPU load and the site is now manageable with clearlrly documented functions.

    This slideshow is full of holes (security and memory) - whether or not these are intentional I don;t know but perhaps show some secure programming when demonstrating the so called 'power' or OOP in php.

    Don't get me wrong .. OOP has it's place in programming but it certainly for the enterprise projects I write it is not better than procedural programming.
    Are you sure you want to
    Your message goes here
  • Goof presentation.
    Are you sure you want to
    Your message goes here
  • thanks, very helpful
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    PHP - Procedural To Object-Oriented PHP - Procedural To Object-Oriented Presentation Transcript

      • 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