logging in or signing up OOPS raghut44 Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 243 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: December 04, 2010 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... By: raghut44 (8 month(s) ago) ok,can you please text me your e-mail id so that i shall share my presentation with you Saving..... Post Reply Close Saving..... Edit Comment Close By: ssunilkumar265103 (8 month(s) ago) hello sir, please send me this ppt i am planning take one session for my students for their campus interview Saving..... Post Reply Close Saving..... Edit Comment Close Premium member Presentation Transcript C H A P T E R S E V E N : C H A P T E R S E V E N More Object-Oriented Programming Slide 2: First introduced scope rules for data hiding. Public part consists of variables and functions that are visible outside of the module. Private part consists of variables and functions visible only within the module. Modules may span multiple compilation units (files). Modules generally lack any inheritance mechanism. Modules Why OO-Programming? : Why OO-Programming? Reduces conceptual load by reducing amount of detail Provides fault containment Can’t use components (e.g., a class) in inappropriate ways Provides independence between components Design/development can be done by more than one person Slide 4: Global Variables -lifetime spans program execution. Local Variables - lifetime limited to execution of a single routine. Nested Scopes - allow functions to be local. Static Variables - visible in single scope. Modules - allow several subroutines to share a set of static variables. Module Types - multiple instances of an abstraction. Classes - families of related abstractions. The Evolution of OOPS Slide 5: An instance of a class is know as an Object. Languages that are based on classes are know as Object-Oriented. Eiffel C++ Modula-3 Ada 95 Java Keys to OO Programming Slide 6: Encapsulation (data hiding) Enable programmer to group data & subroutines (methods) together, hiding irrelevant details from users Inheritance Enable a new abstraction (i.e., derived class) to be defined as an extension of an existing abstraction, retaining key characteristics Dynamic method binding Enable use of new abstraction (i.e., derived class) to exhibit new behavior in context of old abstraction Keys to OO Programming Slide 7: Choosing a constructor How are constructors supported in the language? References and values Value model object creation results from elaboration Execution order of initialization E.g., with derived classes Garbage Collection? Don’t need destructors! Initialization & Finalization of Objects Slide 8: An Example in C++ Slide 9: An Example in C++ References& Values : References& Values Initialization in C++ This is NOT assignment!!! This IS assignment!!! Slide 11: C++ automatically calls constructors for base classes before current constructor Base class members can be explicitly initialized using foo::foo (foo args) : bar (bar args), member1 (m1 args), member2 (m2 args) { … } Use of this syntax results in call to copy constructor rather than 0-arg constructor followed by operator= Java, like C++, by default calls 0-argument versions of base class constructors Call to super (args) overrides 0-arg version Initialization & Finalization of Objects Classes : Classes Extends the scope rules of modules to include inheritance. Should private members of a base class be visible in derived classes? Should public members of a base class always be public members of a derived class. How much control should a base class have over its members in derived classes? Yikes! : Yikes! Huge families of classes are used to implement language features. This is from Smalltalk-80. C++ Classes : C++ Classes Any class can limit the visibility of its members: Public members are visible anywhere the class is in scope. Private members are visible only within the class’s methods. Protected members are visible inside members of the class and derived classes. Friend classes are granted exceptions to (some) of the rules. C++ Classes : C++ Classes Derived classes can further restrict visibility of base class members, but not increase it: Private members of a base class are never visible in a derived class. Protected and public members of a public base class are protected or public, respectively, in a derived class. Protected and public members of a protected base class are protected members of a derived class. Protected and public members of a private base class are private members of a derived class. C++ Classes : C++ Classes Derived classes that limit visibility of base class members can restore visibility by inserting a using declaration in its protected or public sections. Rules in other languages can be significantly different. Dynamic Method Binding : Dynamic Method Binding Dynamic Method Binding : Dynamic Method Binding Member Lookup : Member Lookup Virtual Methods : Virtual Methods Inheritance : Inheritance Multiple Inheritance : Multiple Inheritance Multiple Inheritance : Multiple Inheritance Multiple Inheritance : Multiple Inheritance The vtable entry contains the “this” correction for each method Replicated Inheritance : Replicated Inheritance Replicated Inheritance : Replicated Inheritance Shared Multiple Inheritance : Shared Multiple Inheritance “A new opportunity for ambiguity and additional implementation complexity” Shared Multiple Inheritance : Shared Multiple Inheritance Shared Multiple Inheritance : Shared Multiple Inheritance Mixed Inheritance : Mixed Inheritance A base class composed entirely of abstract methods is called an interface (at least in Java). It has no data nor implements any methods. Inheritance from one real base class and any number of interfaces is called mixed inheritance. Virtual methods of the interface(s) are “mixed into” the methods of the derived class. Mixed Inheritance : Mixed Inheritance Summary : Summary Object Oriented Programming has become an important mainstay of software development. OOP language implementation trades off functionality and “purity” on one hand and simplicity and speed on the other. Treating variables as references rather than static values requires simpler semantics but imposes runtime performance costs due to extra indirection. Summary : Summary Garbage collection makes programming easier but has high run-time costs. Dynamic method binding requires the use of vtables or other lookup mechanism. Multiple inheritance adds extra complexity to the vtable mechanism (even if unused). Shared multiple inheritance adds even more indirection and run-time cost. In-line subroutines can greatly improve performance at the cost of program size. Summary : Summary Smalltalk is considered the “purest” OO language even though it lacks multiple inheritance. Because it is slow it is rarely used in a commercial setting. C++ is most widely used because it has default static binding, minimal dynamic checks, and some very good compilers. Java is more of a niche player, scoring strongly in the internet and portable interface realms. It also tends to be slow. Slide 35: Next time… Functional Programming You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
OOPS raghut44 Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 243 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: December 04, 2010 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... By: raghut44 (8 month(s) ago) ok,can you please text me your e-mail id so that i shall share my presentation with you Saving..... Post Reply Close Saving..... Edit Comment Close By: ssunilkumar265103 (8 month(s) ago) hello sir, please send me this ppt i am planning take one session for my students for their campus interview Saving..... Post Reply Close Saving..... Edit Comment Close Premium member Presentation Transcript C H A P T E R S E V E N : C H A P T E R S E V E N More Object-Oriented Programming Slide 2: First introduced scope rules for data hiding. Public part consists of variables and functions that are visible outside of the module. Private part consists of variables and functions visible only within the module. Modules may span multiple compilation units (files). Modules generally lack any inheritance mechanism. Modules Why OO-Programming? : Why OO-Programming? Reduces conceptual load by reducing amount of detail Provides fault containment Can’t use components (e.g., a class) in inappropriate ways Provides independence between components Design/development can be done by more than one person Slide 4: Global Variables -lifetime spans program execution. Local Variables - lifetime limited to execution of a single routine. Nested Scopes - allow functions to be local. Static Variables - visible in single scope. Modules - allow several subroutines to share a set of static variables. Module Types - multiple instances of an abstraction. Classes - families of related abstractions. The Evolution of OOPS Slide 5: An instance of a class is know as an Object. Languages that are based on classes are know as Object-Oriented. Eiffel C++ Modula-3 Ada 95 Java Keys to OO Programming Slide 6: Encapsulation (data hiding) Enable programmer to group data & subroutines (methods) together, hiding irrelevant details from users Inheritance Enable a new abstraction (i.e., derived class) to be defined as an extension of an existing abstraction, retaining key characteristics Dynamic method binding Enable use of new abstraction (i.e., derived class) to exhibit new behavior in context of old abstraction Keys to OO Programming Slide 7: Choosing a constructor How are constructors supported in the language? References and values Value model object creation results from elaboration Execution order of initialization E.g., with derived classes Garbage Collection? Don’t need destructors! Initialization & Finalization of Objects Slide 8: An Example in C++ Slide 9: An Example in C++ References& Values : References& Values Initialization in C++ This is NOT assignment!!! This IS assignment!!! Slide 11: C++ automatically calls constructors for base classes before current constructor Base class members can be explicitly initialized using foo::foo (foo args) : bar (bar args), member1 (m1 args), member2 (m2 args) { … } Use of this syntax results in call to copy constructor rather than 0-arg constructor followed by operator= Java, like C++, by default calls 0-argument versions of base class constructors Call to super (args) overrides 0-arg version Initialization & Finalization of Objects Classes : Classes Extends the scope rules of modules to include inheritance. Should private members of a base class be visible in derived classes? Should public members of a base class always be public members of a derived class. How much control should a base class have over its members in derived classes? Yikes! : Yikes! Huge families of classes are used to implement language features. This is from Smalltalk-80. C++ Classes : C++ Classes Any class can limit the visibility of its members: Public members are visible anywhere the class is in scope. Private members are visible only within the class’s methods. Protected members are visible inside members of the class and derived classes. Friend classes are granted exceptions to (some) of the rules. C++ Classes : C++ Classes Derived classes can further restrict visibility of base class members, but not increase it: Private members of a base class are never visible in a derived class. Protected and public members of a public base class are protected or public, respectively, in a derived class. Protected and public members of a protected base class are protected members of a derived class. Protected and public members of a private base class are private members of a derived class. C++ Classes : C++ Classes Derived classes that limit visibility of base class members can restore visibility by inserting a using declaration in its protected or public sections. Rules in other languages can be significantly different. Dynamic Method Binding : Dynamic Method Binding Dynamic Method Binding : Dynamic Method Binding Member Lookup : Member Lookup Virtual Methods : Virtual Methods Inheritance : Inheritance Multiple Inheritance : Multiple Inheritance Multiple Inheritance : Multiple Inheritance Multiple Inheritance : Multiple Inheritance The vtable entry contains the “this” correction for each method Replicated Inheritance : Replicated Inheritance Replicated Inheritance : Replicated Inheritance Shared Multiple Inheritance : Shared Multiple Inheritance “A new opportunity for ambiguity and additional implementation complexity” Shared Multiple Inheritance : Shared Multiple Inheritance Shared Multiple Inheritance : Shared Multiple Inheritance Mixed Inheritance : Mixed Inheritance A base class composed entirely of abstract methods is called an interface (at least in Java). It has no data nor implements any methods. Inheritance from one real base class and any number of interfaces is called mixed inheritance. Virtual methods of the interface(s) are “mixed into” the methods of the derived class. Mixed Inheritance : Mixed Inheritance Summary : Summary Object Oriented Programming has become an important mainstay of software development. OOP language implementation trades off functionality and “purity” on one hand and simplicity and speed on the other. Treating variables as references rather than static values requires simpler semantics but imposes runtime performance costs due to extra indirection. Summary : Summary Garbage collection makes programming easier but has high run-time costs. Dynamic method binding requires the use of vtables or other lookup mechanism. Multiple inheritance adds extra complexity to the vtable mechanism (even if unused). Shared multiple inheritance adds even more indirection and run-time cost. In-line subroutines can greatly improve performance at the cost of program size. Summary : Summary Smalltalk is considered the “purest” OO language even though it lacks multiple inheritance. Because it is slow it is rarely used in a commercial setting. C++ is most widely used because it has default static binding, minimal dynamic checks, and some very good compilers. Java is more of a niche player, scoring strongly in the internet and portable interface realms. It also tends to be slow. Slide 35: Next time… Functional Programming