Object Oriented Concept

6,598 views

Published on

Published in: Technology

Object Oriented Concept

  1. 1. Object Oriented Concepts Sarfaraz M Manik
  2. 2. Content Overview <ul><li>Procedural Approach Vs Object Oriented Approach. </li></ul><ul><li>Object and Class </li></ul><ul><li>Object Identification using CRC </li></ul><ul><li>Encapsulation </li></ul><ul><li>Inheritance </li></ul><ul><li>Polymorphism </li></ul><ul><li>Composition </li></ul><ul><li>Properties and Constructor </li></ul><ul><li>Interface </li></ul><ul><li>Abstract Class and Methods </li></ul>
  3. 3. What is Object-Orientation? <ul><li>A Technique for System Modeling </li></ul><ul><li>Model: A model is an abstraction of something. It helps us to understand an aspect of reality. </li></ul><ul><ul><li>Examples: Highway Map, Architectural Models, Mechanical Models. </li></ul></ul>
  4. 5. <ul><li>John </li></ul>Object Oriented Model Car Tree House lives in drives
  5. 6. What is an Object? <ul><li>An object is: </li></ul><ul><ul><li>Something tangible (e.g. John, Car) </li></ul></ul><ul><ul><li>Something that can be apprehended intellectually (e.g. DOB, time, account) </li></ul></ul>
  6. 7. What is an Object? <ul><li>An object has: </li></ul><ul><ul><li>State (attributes) </li></ul></ul><ul><ul><li>Behavior (operations) </li></ul></ul><ul><ul><li>Unique Identity </li></ul></ul>
  7. 8. Example: John is a tangible object <ul><ul><li>State (attributes) </li></ul></ul><ul><ul><ul><li>Name </li></ul></ul></ul><ul><ul><ul><li>Age </li></ul></ul></ul><ul><ul><li>Behavior (operations) </li></ul></ul><ul><ul><ul><li>Eats </li></ul></ul></ul><ul><ul><ul><li>Drives </li></ul></ul></ul><ul><ul><li>Unique Identity </li></ul></ul><ul><ul><ul><li>Name </li></ul></ul></ul>
  8. 9. Example-1: Date is a tangible object <ul><ul><li>State (attributes) </li></ul></ul><ul><ul><ul><li>Name </li></ul></ul></ul><ul><ul><ul><li>Age </li></ul></ul></ul><ul><ul><li>Behavior (operations) </li></ul></ul><ul><ul><ul><li>Eats </li></ul></ul></ul><ul><ul><ul><li>Drives </li></ul></ul></ul><ul><ul><li>Unique Identity </li></ul></ul><ul><ul><ul><li>Name </li></ul></ul></ul>
  9. 10. Example-2: Car is a tangible object <ul><ul><li>State (attributes) </li></ul></ul><ul><ul><ul><li>Model </li></ul></ul></ul><ul><ul><ul><li>Color </li></ul></ul></ul><ul><ul><li>Behavior (operations) </li></ul></ul><ul><ul><ul><li>Accelerate </li></ul></ul></ul><ul><ul><ul><li>Change Gear </li></ul></ul></ul><ul><ul><li>Unique Identity </li></ul></ul><ul><ul><ul><li>Registration Number </li></ul></ul></ul>
  10. 11. Example-3: Time is an object intellectually apprehended <ul><ul><li>State (attributes) </li></ul></ul><ul><ul><ul><li>Hours </li></ul></ul></ul><ul><ul><ul><li>Minutes </li></ul></ul></ul><ul><ul><ul><li>Seconds </li></ul></ul></ul><ul><ul><li>Behavior (operations) </li></ul></ul><ul><ul><ul><li>Get hours, Get minutes, Get seconds </li></ul></ul></ul><ul><ul><ul><li>Set hours, Set minutes, Set seconds </li></ul></ul></ul><ul><ul><li>Unique Identity </li></ul></ul><ul><ul><ul><li>Lunch Time or Study Time </li></ul></ul></ul>
  11. 12. Another Example: <ul><li>“ … customers are allowed to have different types of bank accounts , deposit money , withdraw money and transfer money between accounts ” </li></ul>
  12. 13. Procedural vs. Object-Oriented <ul><li>Procedural </li></ul><ul><li>Withdraw, deposit, transfer </li></ul><ul><li>Object Oriented </li></ul><ul><li>Customer, money, account </li></ul>
  13. 14. Procedural Approach <ul><li>Focus is on procedures </li></ul><ul><li>All data is shared: no protection </li></ul><ul><li>More difficult to modify </li></ul><ul><li>Hard to manage complexity </li></ul>
  14. 15. Advantages of Object Orientation <ul><li>People think in terms of object </li></ul><ul><li>OO models map to reality </li></ul><ul><li>OO models are: </li></ul><ul><ul><li>Easy to develop </li></ul></ul><ul><ul><li>Easy to understand. </li></ul></ul>
  15. 16. Objects and Classes <ul><li>Classes reflect concepts, objects reflect instances that embody those concepts. </li></ul>girl class object Daria Jane Brittany Jodie
  16. 17. Objects and Classes <ul><li>Classes are templates based on which objects are created. </li></ul><ul><ul><li>For e.g. Book is a class but a particular book like Programming with C# is an object of the book class. </li></ul></ul>
  17. 18. Conclusion <ul><li>OO = encapsulation + inheritance </li></ul><ul><li>modularity -- autonomous entities, cooperation through exchanges of messages </li></ul><ul><li>deferred commitment -- the internal workings of an object can be redefined without changing other parts of the system </li></ul><ul><li>reusability -- refining classes through inheritance </li></ul><ul><li>naturalness -- object-oriented analysis/design, modeling </li></ul>

×