Object-Oriented Programming (OOP) Lecture No. 5. Multiple Inheritance ► We may want to reuse characteristics of more than one parent class.

Slides:



Advertisements
Similar presentations
UML an overview.
Advertisements

OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Downloaded From:  We may want to reuse characteristics of more than one parent class Downloaded From:
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
L3-1-S1 OO Concepts © M.E. Fayad SJSU -- CMPE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS6th Edition.
Chapter 14 (Web): Object-Oriented Data Modeling
May-June 2001 ISISTAN Research Institute – Tandil, Argentina Software Design Methodologies: UML in Action Dr. Mohamed Fayad, J.D. Edwards Professor Department.
7M822 UML Class Diagrams advanced concepts 15 September 2008.
Object-Oriented Programming (OOP) Lecture No. 5 Downloaded From:
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Chapter 2: Entity-Relationship Model (Continued)
Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – ER Model.
Chapter 14: Object-Oriented Data Modeling
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
01 November 2007Kaiser: COMS W4156 Fall COMS W4156: Advanced Software Engineering Prof. Gail Kaiser
COMS W4156: Advanced Software Engineering
OBJECT ORIENTED PROGRAMMING LECTURE 12 Instructor: Rashi Garg Coordinator: Gaurav Saxena.
Entities and Attributes
Lawrence ChungCS6359.0T1: Module 41 Module 4: Relationships.
CSC241 Object-Oriented Programming (OOP) Lecture No. 19.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part V: Design The Design Workflow Design Classes Refining Analysis Relationships.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Object-Oriented Programming (OOP) CSC-2071 (3+1=4 Credits) Lecture No. 1 MBY.
Association Class Generalization/Specialization Whole-Part Page More Associations 1.
Software Engineering, 8th edition Chapter 8 1 Courtesy: ©Ian Somerville 2006 April 06 th, 2009 Lecture # 13 System models.
CHAPTER 13 (ONLINE): OBJECT-ORIENTED DATA MODELING © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
7-1 © Prentice Hall, 2007 Chapter 7: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Unit 3 Conceptual Data Modeling. Key Concepts Conceptual data modeling process Classes and objects Attributes Identifiers, candidate keys, and primary.
7-1 © Prentice Hall, 2007 Week 5: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
CS212: Object Oriented Analysis and Design Lecture 13: Relationship between Classes.
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
UML Class Diagrams 1 These lecture slides are copyright (C) Marty Stepp, They may not be rehosted, sold, or modified without expressed permission.
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
CSC241 Object-Oriented Programming (OOP) Lecture No. 3.
Lecture 1: UML Class Diagram September 12, UML Class Diagrams2 What is a Class Diagram? A class diagram describes the types of objects in the system.
Class Diagram Classes are the most important building block of any object-oriented system. A class is a description of a set of objects that share the.
Chapter 5 System Modeling Sommerville, "software engineering ", 9 th Ed., 2011.
ITEC 3220A Using and Designing Database Systems Instructor: Prof Z. Yang Course Website: 3220a.htm
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
Data Modeling Using the Entity-Relationship (ER) Data Model (Based on Chapter 3 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)
CSCI-383 Object-Oriented Programming & Design Lecture 10.
1 Software Engineering Dr. K. T. Tsang Lecture 5 Class modeling
Pick of the day 10-Jan-2003 Lecture 2 Crash course on OO Analysis Models.
Database Design – Lecture 12 Object Oriented Database Design cont’d.
Chapter 12 Object-oriented design for more than one class.
Data Modeling Using the Entity-Relationship (ER) Data Model.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
Association / Aggregation / Composition and inheritance
Chapter 5 System Modeling. What is System modeling? System modeling is the process of developing abstract models of a system, with each model presenting.
1 CSC241: Object Oriented Programming Lecture No 17.
CLASS DIAGRAMS A classy approach to objects. The Basic Class Diagram  Class Name  Attributes (- indicates private each would have properties or accessor/mutator.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
 To explain why the context of a system should be modelled as part of the RE process  To describe behavioural modelling, data modelling and object modelling.
Class Diagram Lecture # 1. Class diagram A Class Diagram is a diagram describing the structure of a system shows the system's classes Attributes operations.
Object-Oriented Paradigm (OOP) Course Code: SE 101 Lecture No. 1.
Object-Oriented Programming (OOP) Lecture No. 1. Course Objective ► Objective of this course is to make students familiar with the concepts of object-oriented.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Object Oriented Programming
Object-Oriented Modeling
OBJECT ORIENTED CONCEPT
OBJECT RELATIONSHIPS, ATTRIBUTES, AND METHODS
Software Engineering Lecture #11.
UML Class Diagram.
Systems Analysis – ITEC 3155 Modeling System Requirements – Part 2
Object-Oriented Programming (OOP) Lecture No. 5
Object Oriented Analysis and Design
Presentation transcript:

Object-Oriented Programming (OOP) Lecture No. 5

Multiple Inheritance ► We may want to reuse characteristics of more than one parent class

Example – Multiple Inheritance Mermaid

Example – Multiple Inheritance Mermaid WomanFish

Example – Multiple Inheritance Amphibious Vehicle

Example – Multiple Inheritance Amphibious Vehicle Land VehicleWater Vehicle Vehicle CarBoat

Problems with Multiple Inheritance ► Increased complexity ► Reduced understanding ► Duplicate features

Problem – Duplicate Features Mermaid WomanFish eat … eat … ► Which eat operation Mermaid inherits?

Solution – Override the Common Feature Mermaid WomanFish eat … eat … eat … Invoke eat operation of desired class

Problem – Duplicate Features (Diamond Problem) ► Which changeGear operation Amphibious Vehicle inherits? Amphibious Vehicle Land VehicleWater Vehicle Vehicle CarBoat changeGear

Solution to Diamond Problem ► Some languages disallow diamond hierarchy ► Others provide mechanism to ignore characteristics from one side

Association ► Objects in an object model interact with each other ► Usually an object provides services to several other objects ► An object keeps associations with other objects to delegate tasks

Kinds of Association ► Class Association  Inheritance ► Object Association  Simple Association  Composition  Aggregation

Simple Association ► Is the weakest link between objects ► Is a reference by which one object can interact with some other object ► Is simply called as “association”

Kinds of Simple Association ► w.r.t navigation  One-way Association  Two-way Association ► w.r.t number of objects  Binary Association  Ternary Association  N-ary Association

One-way Association ► We can navigate along a single direction only ► Denoted by an arrow towards the server object

Example – Association ► Ali lives in a House AliHouse lives-in 1 1

Example – Association ► Ali drives his Car AliCar drives * 1

Two-way Association ► We can navigate in both directions ► Denoted by a line between the associated objects

Example – Two-way Association EmployeeCompany works-for 1 * ► Employee works for company ► Company employs employees

Example – Two-way Association YasirAli friend 1 1 ► Yasir is a friend of Ali ► Ali is a friend of Yasir

Binary Association ► Associates objects of exactly two classes ► Denoted by a line, or an arrow between the associated objects

Example – Binary Association ► Association “works-for” associates objects of exactly two classes EmployeeCompany works-for 1 *

Example – Binary Association ► Association “drives” associates objects of exactly two classes AliCar drives * 1

Ternary Association ► Associates objects of exactly three classes ► Denoted by a diamond with lines connected to associated objects

Example – Ternary Association ► Objects of exactly three classes are associated StudentTeacher Course 1 * *

Example – Ternary Association ProjectLanguage Person ► Objects of exactly three classes are associated * 1 *

N-ary Association ► An association between 3 or more classes ► Practical examples are very rare

Composition ► An object may be composed of other smaller objects ► The relationship between the “part” objects and the “whole” object is known as Composition ► Composition is represented by a line with a filled-diamond head towards the composer object

Example – Composition of Ali Ali Body Arm Head Leg

Example – Composition of Chair Chair SeatArm Back Leg

Composition is Stronger ► Composition is a stronger relationship, because  Composed object becomes a part of the composer  Composed object can’t exist independently

Example – Composition is Stronger ► Ali is made up of different body parts ► They can’t exist independent of Ali

Example – Composition is Stronger ► Chair’s body is made up of different parts ► They can’t exist independently

Aggregation ► An object may contain a collection (aggregate) of other objects ► The relationship between the container and the contained object is called aggregation ► Aggregation is represented by a line with unfilled-diamond head towards the container

Example – Aggregation Room Cupboard Bed ChairTable * 1 1 1

Example – Aggregation GardenPlant *

Aggregation is Weaker ► Aggregation is weaker relationship, because  Aggregate object is not a part of the container  Aggregate object can exist independently

Example – Aggregation is Weaker ► Furniture is not an intrinsic part of room ► Furniture can be shifted to another room, and so can exist independent of a particular room

Example – Aggregation is Weaker ► A plant is not an intrinsic part of a garden ► It can be planted in some other garden, and so can exist independent of a particular garden