+ All Categories
Home > Education > Oops lecture 1,2

Oops lecture 1,2

Date post: 19-Nov-2014
Category:
Upload: shashank12march
View: 541 times
Download: 3 times
Share this document with a friend
Description:
 
Popular Tags:

of 20

Click here to load reader

Transcript
  • 1. Object Oriented Programming Lecture 1,2 Presented By:Shashank Srivastava27 July,2012

2. Problems With Procedural Languages Data does not have an owner. Difficult to maintain data integrity. Functions are the building blocks. Many functions can modify a given block of data. Difficult to pin point bug sources when data is corrupted.216 August 2012 3. Problems With Procedural Languages( Cont)Function 1 Function 2 DATAFunction 33 16 August 2012 4. Problems With Procedural LanguagesUninitialized Variablesint k;printf(%d, k);Output ???416 August 2012 5. Problems With Procedural LanguagesInsufficient support for abstraction ADT = Data + FunctionData: Modeled as structurefunction : global , not related to structure516 August 2012 6. Problems With Procedural Languages Insufficient support for abstraction(How???) struct horse struct eagle {{weight, color, age; age, weight, wingspan }; };gallop();fly();canter();hunt(); All Functions are Global616 August 2012 7. Better Abstraction using OO Languages class horseclass eagle {{ weight, color, age;age, weight, wingspangallop();fly();canter();Class= State + Behaviorhunt();} }7 16 August 2012 8. Class= State + BehaviorState:data members ( C++)Fields (Java)Behavior:Member functions (C++)Methods ( Java)8 16 August 2012 9. ObjectAn object has state, exhibits some well-define behavior, and has a unique identity.9 16 August 2012 10. Class A class is a set of objects that share acommon structure and a commonbehavior.1016 August 2012 11. Problem with My Public Garden11 16 August 2012 12. Solution 1: Build A High fence Fence12 16 August 2012 13. Solution 2: Private Garden with Guards13 16 August 2012 14. Write functions to safeguard data14 16 August 2012 15. Write function codevoid modify_x( int newval) {if( newval>100||newval


Recommended