Software Development - Thinking Object's Way

335 views

Published on

Published in: Design, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
335
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Software Development - Thinking Object's Way

  1. 1. Object Oriented Concepts Thinking Object’s way -Sanjay Gadge (sgadge@gmail.com)
  2. 2. What is Object?
  3. 3. What is Object?• Tangible entity and close to real world• It has state and behavior• It has responsibilities, it has to adhere to• It expects respect from rest of the world• It provides services to other objects• World is collection of collaborating entities called “objects”• Object is born and it has to die
  4. 4. OO Paradigm • Encapsulation • Abstraction • Inheritance • Polymorphism • Composition
  5. 5. Abstraction• An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer• Focuses upon the observable behavior of the object
  6. 6. Abstraction• Abstraction provides reusability• More generic than specific – “Take me to airport” Vs “Turn Left”, “Turn Right”, “Start”, “Stop”• Abstraction provides a mean to divide and conquer problem statement• Abstraction helps in pattern identification• Abstract classes and Interfaces
  7. 7. EncapsulationEncapsulation means:• Information hiding• Hiding details : Don’t tell me how do you do it, just do it.
  8. 8. Encapsulation• An object should only expose the services required to interact with it. Details not important to the user of the object should be hidden• Services are implemented by the object• # of services should be kept minimal• Any local changes (algorithm/data) will not affect the service provided. This makes system resilient.• Services provided by the object should be seen as a contract between user-of-the-object and object-under-discussion. Both the parties should honor the contract.• The scope of data manipulation code is limited to the object thus provides better control on the data.• Give the user objects only what they absolutely needs• Services are exposed as “public” access-modifier
  9. 9. Inheritance• “Is-a” relationship• Helps in code/services reuse• Helps in locating the common code at one place hence a common change can be applied at one place only. Hence less maintenance efforts & increased readability• Base class services can be used as-it-is or can be overridden
  10. 10. Polymorphism• Literal meaning: many Shape { shapes } public void Draw();• Provides analogous Circle Rectangle interface (with different { public void Draw() { public void Draw() implementation) to { } { } users of object } }• Polymorphism- Abstraction-inheritance often go hand in hand
  11. 11. Using “private, public, protected”wiselyPrivate• Internal to object – Class level variables – Sub routines• Does not make much sense out side the object boundaries – Helper methods• Needs to be secured/shielded from out side world – Variables holding important information crucial for algorithms and values needs to be checked before assigning/setting• Contributes to the stable-state of the object – Object attributes
  12. 12. ………Using “private, protected, public”wiselyProtected• Internal to object and its derived objects and Does not make much sense out side the object boundaries but may be assessed by derived objects – Helper methodsPublic• Only meant for out side world• Mostly represent the services provided by object• Can be overridden by derived objects
  13. 13. Thank you!

×