Applying OO Concepts

756 views

Published on

Applying Object-oriented concepts!

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
756
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
37
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Applying OO Concepts

  1. 1. Applying Object Oriented Concepts -by Mohammed Irfan
  2. 2. Fundamental OO Concepts <ul><li>Encapsulation </li></ul><ul><li>Inheritance </li></ul><ul><li>Polymorphism </li></ul>
  3. 3. Encapsulation <ul><li>“ What you hide you can change” </li></ul><ul><li>“ Encapsulate what varies” (GoF) </li></ul><ul><li>“ Encapsulation != Wrapping” </li></ul>
  4. 4. Inheritance <ul><li>Is-a relationship </li></ul><ul><li>But remember the LSP (Liskov Substitute Principle) </li></ul><ul><li>“ If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T.” </li></ul><ul><li>We should only extend Abstract classes (GoF) </li></ul>
  5. 5. Abstract Class-Interface <ul><li>Used to structure class hierarchies </li></ul><ul><li>Facilitate implementing Polymorphism </li></ul><ul><li>Don’t confuse interface with language construct interface </li></ul><ul><li>Interface is the external view of the object (class) </li></ul><ul><li>“ Program to interface and not to implementation ” (GoF) </li></ul>
  6. 6. Inheritance Example Is-a Relationship
  7. 7. Polymorphism <ul><li>Single interface, multiple implementations </li></ul><ul><li>Two flavors: </li></ul><ul><ul><li>Overriding : Closely related with inheritance </li></ul></ul><ul><ul><li>Overloading: Can be implemented with __call() magic method in PHP5 </li></ul></ul>
  8. 8. Improved Example Has-a Relationship
  9. 9. Case Study <ul><li>An object-oriented Session handling library (SAL) </li></ul><ul><ul><li>An SAL to allow storing of session to different storage mechanisms, e.g., Native PHP Sessions, File Storage, Database, Cookies etc. </li></ul></ul>
  10. 10. What to look for in SAL? <ul><li>It should be reusable </li></ul><ul><li>It should be easy to modify (maintainable and extensible) </li></ul><ul><li>Should follow some of the principals: </li></ul><ul><ul><li>DRY : Don’t Repeat Yourself </li></ul></ul><ul><ul><li>Simplest thing that could possibly work </li></ul></ul>
  11. 11. Class Diagram
  12. 12. Where to study more? (Books) <ul><li>PHP in Action </li></ul><ul><li>Agile Software Development: Principals, Patterns, and Practices </li></ul><ul><li>Applying UML and Patterns </li></ul><ul><li>Design Patterns (GoF Book) </li></ul><ul><li>Fundamentals of Object-Oriented Design in UML </li></ul><ul><li>UML Distilled </li></ul><ul><li>Pragmatic Programmer </li></ul>
  13. 13. Thank you! 

×