Ceg860 (Prasad)L13MI1 Multiple Inheritance DAG Class Structure : Directed Acyclic Graph.

Slides:



Advertisements
Similar presentations
Inheritance Inheritance Reserved word protected Reserved word super
Advertisements

Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Learners Support Publications Inheritance: Extending Classes.
1 Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 10.
Chair of Software Engineering OOSC Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Bertrand Meyer Object-Oriented Software Construction Lecture 8: More on inheritance.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
1 Chapter 6 Inheritance, Interfaces, and Abstract Classes.
Chair of Software Engineering ATOT - Lecture 9, 30 April Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Lecture 21 1 Object-Oriented Software Construction Bertrand Meyer.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Object-oriented concepts.
Operator Overloading: indexing Useful to create range-checked structures: class four_vect { double stor[4]; // private member, actual contents of vector.
Tutorial 4 Creating Special Effects with CSS
Chair of Software Engineering ATOT - Lecture 14, 19 May Advanced Topics in Object Technology Bertrand Meyer.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 24: Dynamic Binding COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos.
7M822 Software Engineering: System Models 14 September 2009.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 20: Multiple inheritance.
Inheritance and Polymorphism CS351 – Programming Paradigms.
Chair of Software Engineering ATOT - Lecture 22, 18 June Advanced Topics in Object Technology Bertrand Meyer.
© Copyright Eliyahu Brutman Programming Techniques Course Version 1.0.
1 Chapter 14-2 Object- Oriented Software Development Dale/Weems.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
1 Classes- Inheritance Multiple Inheritance It is possible to derive a new class from more than one base class. This is called Multiple Inheritance. Under.
Chapter 11: Inheritance and Composition. Objectives In this chapter, you will: – Learn about inheritance – Learn about derived and base classes – Redefine.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
Day Virtual versus static methods. 2. Polymorphism 3. Detailed worked example. 4. Abstract classes.
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
ProgrammingLanguages Programming Languages Object-oriented Programming Languages This lecture discusses the concept of object- oriented programming.
© S Ramakrishnan, Monash University oops1.ppt 1 Object-Oriented Programming Systems SFT3021 Semester Lecturer: Sita Ramakrishnan
Object Oriented Programming with C++/ Session 6 / 1 of 44 Multiple Inheritance and Polymorphism Session 6.
Multiple Inheritance Mark Hennessy Dept. Computer Science NUI Maynooth C++ Workshop 18 th – 22 nd September 2006.
SFDV4001 / OOP with C++ / Lecture 4 / Polymorphism 1 L4: Multiple Inheritance Introduction Problems of Single Inheritance and solutions Problems of Multiple.
TextBook Concepts of Programming Languages, Robert W. Sebesta, (10th edition), Addison-Wesley Publishing Company CSCI18 - Concepts of Programming languages.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
CSSE501 Object-Oriented Development. Chapter 13: Multiple Inheritance  In this chapter we will investigate some of the problems that can arise when a.
Operator Overloading: indexing Useful to create range-checked structures: class four_vect { double stor[4]; // private member, actual contents of vector.
Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives  Inheritance  Virtual Function.
C++ Inheritance Data Structures & OO Development I 1 Computer Science Dept Va Tech June 2007 © McQuain Generalization versus Abstraction Abstraction:simplify.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 13: Inheritance and Composition.
Ceg860 (Prasad)L17IT1 Inheritance Techniques Subcontracting Anchored Types.
Object Oriented Design Lecture #4 – Inheritance, Interfaces, Classes Tomasz Pieciukiewicz.
Chapter 11: Inheritance and Composition. Introduction Two common ways to relate two classes in a meaningful way are: – Inheritance (“is-a” relationship)
CSCI 383 Object-Oriented Programming & Design Lecture 19 Martin van Bommel.
Inheritance in C++ Bryce Boe 2012/08/28 CS32, Summer 2012 B.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
1 Lecture 23: Dynamic Binding (Section ) CSCI 431 Programming Languages Fall 2002 A compilation of material developed by Felix Hernandez-Campos.
Polymorphism and Inheritance (CS-319 Supplementary Notes)
COMPUTER SCIENCE & TECHNOLOGY DEGREE PROGRAMME FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UVA WELLASSA ‏ Properties of Object Oriented Programming.
Inheritance Techniques
Types of Programming Languages
The OO Solution The OO model closely resembles the problem domain
Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach
Inheritance, Polymorphism, and Interfaces. Oh My
Learning Objectives Inheritance Virtual Function.
MSIS 670 Object-Oriented Software Engineering
Einführung in die Programmierung Introduction to Programming Prof. Dr
Chapter 11: Inheritance and Composition
Chapter 7: Entity-Relationship Model
Assignments cs7100(Prasad) L13Assg.
Object Oriented Programming(OOP)
C++ Object Oriented 1.
Programming in C# CHAPTER 5 & 6
Computer Science II for Majors
Presentation transcript:

ceg860 (Prasad)L13MI1 Multiple Inheritance DAG Class Structure : Directed Acyclic Graph

ceg860 (Prasad)L13MI2 Examples in System Modeling combination Multiple inheritance facilitates combination of (orthogonal) abstractions. Company plane Airplane ( Pilot’s perspective ) (queries) passenger_count, altitude, position, speed, etc. (commands) take_off, land, set_speed, etc. Asset ( Accountant’s perspective ) (features) purchase_price, resale_value, depreciate, etc. Dining car Train car (coach) Restaurant Watch calculator

ceg860 (Prasad)L13MI3 roles Multiple inheritance facilitates representation of various roles of an object. Sofa bed, Mobile home,...  Knowledge Representation  Clinton is a father.  Clinton is the ex-President of USA.  Nixon was a Republican.  Nixon was a Quaker.  Dolphins are aquatic creatures.  Dolphins are mammals.

ceg860 (Prasad)L13MI4 Examples from Software Systems Window ( Hierarchical Structure ) Tree »(features) listOfSubwindows, parentWindow, addWindow, removeWindow, etc. ( Graphical Object ) Rectangle »(features) height, width, position, display, hide, etc.

ceg860 (Prasad)L13MI5 Tree List »(features) countChildren, leftMostChild, addChild, removeChild, etc. Cell »(features) parent, nextSibling, etc. Linked list ( leftmost child right sibling )

ceg860 (Prasad)L13MI6 Graphics Example Composite_Figure class Composite_Figure extends Figure, LinkedList[Figure] {... void display() { forEachDo { item.display(); }; } void translate() { … }...} Illustrates: multiple inheritance, polymorphic data structure, dynamic binding, recursion, etc.

ceg860 (Prasad)L13MI7 Design Pattern Describing composite structures using multiple inheritance with a container class as a parent More Examples »Menus with Submenus »Compound Commands »Graphical Object Groups

ceg860 (Prasad)L13MI8 Eiffel’s approach to Multiple Inheritance

ceg860 (Prasad)L13MI9 Name Clashes and Feature Renaming Eiffel bans intra-class overloading. feature renamingName clashes resulting from multiple inheritance can be resolved in the child class using feature renaming mechanism. Redeclaration/redefinition changes the feature, but keeps the name. Renaming changes the name, but keeps the feature. Redeclaration is semantic; renaming is syntactic. Renaming also enables class designers to give locally appropriate names to features.

ceg860 (Prasad)L13MI10 Repeated Inheritance Class D is a descendant of class A in more than one way. E.g., A = Driver ( age, address, birthday(), etc.) B = French_Driver C = US_Driver D = US_French_Driver  Share  Share : age  Replicate  Replicate : address A D BC

ceg860 (Prasad)L13MI11 Multiple Inheritance of Features A class that inherits different but identically named features from different parents is invalid. Feature renaming may be used to avoid name clash. Note that this case excludes repeated inheritance. An attribute coming from repeated ancestor is shared, by default. Feature renaming may be used to replicate it. In C++, all the fields of a repeated ancestor are either shared ( virtual ) or duplicated.

ceg860 (Prasad)L13MI12 Transcontinental Drivers in Eiffel classinherit class French_US_Driver inherit French_Driver rename as address as french_address, as violations as french_violations, as pay_fee as french_pay_fee end US_Driver rename as address as us_address, as violations as us_violations, as pay_fee as us_pay_fee end feature feature... // shared : age, name,... end end;

ceg860 (Prasad)L13MI13 Conflicting Redefinitions What if a feature f inherited by class D from repeated ancestor A has been redefined in B and/or C ? v Conflicts under sharing (two impl., one name) Problem: Name Clash  Eiffel provides rename, redefine, and undefine to enable a programmer to disambiguate.

ceg860 (Prasad)L13MI14 (cont’d) Conflicts under replication (two impl., two names) Problem: Ambiguity for Dynamic binding A a = new D(); a.f();  Eiffel provides select to let the programmer pick the appropriate impl. to run for f() on a D via a A -entity.

ceg860 (Prasad)L13MI15 Windows in Eiffel class class Window feature display is … end; classinherit class Window_with_Border inherit Window feature display is … end; classinherit class Window_with_Menu inherit Window feature display is … end; classinherit class Window_with_Border_and_Menu inherit Window_with_Border Window_with_Menu featureis feature display is {Window_with_Border} Precursor; {Window_with_Menu} Precursor; end; Window.display !! Problem: Indirectly invokes Window.display twice!!

ceg860 (Prasad)L13MI16 (Cont’d) classinherit class Window_with_Border_and_Menu inherit Window Window renameas rename id as window_id select select window_id redefineend redefine display end Window_with_Border renameas rename id as border_id redefineend redefine display end Window_with_Menu renameas rename id as menu_id redefineend redefine display end feature feature is display is {Window} Precursor; draw_border; draw_menu; end; end end;