Inheritance Allows extension and reuse of existing code

Slides:



Advertisements
Similar presentations
Data Structures.
Advertisements

1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
© 2010 Bennett, McRobb and Farmer1 Use Case Description Supplementary material to support Bennett, McRobb and Farmer: Object Oriented Systems Analysis.
Stereotypes Stereotypes provide the capability to create a new kind of modeling element. –They can be used to classify or mark modeling elements. –A type.
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
© 2006 Pearson Addison-Wesley. All rights reserved9 A-1 Chapter 9 Advanced Java Topics (inheritance review + Java generics)
Creating Classes from Other Classes Chapter 2 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
Lecture a: Additional UML Models: Package, Activity, Deployment Lecture b: Generalization, Aggregation and Additional Domain Model Notation Copyright W.
Sharif University of Technology Session # 7.  Contents  Systems Analysis and Design  Planning the approach  Asking questions and collecting data 
C++ fundamentals.
Subclasses and Subtypes CMPS Subclasses and Subtypes A class is a subclass if it has been built using inheritance. ▫ It says nothing about the meaning.
Unified Modeling Language
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
CONCEPTS OF OBJECT ORIENTED PROGRAMMING. Topics To Be Discussed………………………. Objects Classes Data Abstraction and Encapsulation Inheritance Polymorphism.
Object Orientation Yaodong Bi, Ph.D. Department of Computer Sciences University of Scranton October 18, 2015October 18, 2015October 18, 2015.
Class diagram Used for describing structure and behaviour in the use cases Provide a conceptual model of the system in terms of entities and their relationships.
UML Class Diagrams 1 These lecture slides are copyright (C) Marty Stepp, They may not be rehosted, sold, or modified without expressed permission.
Using COMET with Visio Visio UML Modeling. Creating a Drawing After opening Visio, you will see a list of templates available.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Learners Support Publications Object Oriented Programming.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Object Orientation Yaodong Bi, Ph.D. Department of Computer Sciences University of Scranton January 12, 2016January 12, 2016January 12, 2016.
Class diagrams Terézia Mézešová.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Fusion Design Overview Object Interaction Graph Visibility Graph Class Descriptions Inheritance Graphs Fusion: Design The overall goal of Design is to.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (2/2)
Object Orientation Yaodong Bi, Ph.D. Department of Computer Sciences University of Scranton August 19, 2005.
ISBN Chapter 12 Support for Object-Oriented Programming.
1 IS 0020 Program Design and Software Tools Unified Modeling Language Lecture 13 April 13, 2005.
1 IS 0020 Program Design and Software Tools Unified Modeling Language Lecture 13 November 30, 2004.
Data Structures Lecture 4: Classes in C++ Azhar Maqsood NUST Institute of Information Technology (NIIT)
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
 Class and Diagram  Representation of Class Name Attributes Operations  Visibility of Attributes and Operations.
CSC 421: Algorithm Design & Analysis
Modeling with UML – Class Diagrams
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Modern Programming Tools And Techniques-I
Inheritance and Polymorphism
Project Management: Messages
Object-Oriented Programming Concepts
UML-Class Diagrams. UML-Class Diagrams Order placement problem A Company has two types of customers, corporate customers and personal customers. All.
Sachin Malhotra Saurabh Choudhary
Unified Modeling Language
Object-Oriented Analysis and Design
Chapter 16 UML Class Diagrams.
Class Diagrams.
Inheritance and Polymorphism
Function Overloading.
OOP What is problem? Solution? OOP
Object Orientation Yaodong Bi, Ph.D. Department of Computer Sciences
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Types of Programming Languages
Object Oriented Concepts
CSC 421: Algorithm Design & Analysis
Inheritance Often, software encapsulates multiple concepts for which some attributes/behaviors overlap E.g. A computer (role-playing) game has: Monsters:
Object Orientation Yaodong Bi, Ph.D. Department of Computer Sciences
Support for Object-Oriented Programming in Ada 95
Advanced Java Topics Chapter 9
ITEC 3220A Using and Designing Database Systems
Review CSE116 2/21/2019 B.Ramamurthy.
Object-Oriented Programming: Inheritance and Polymorphism
Introduction to Data Structure
CIS 199 Final Review.
CSE470 Software Engineering UML Lecture.  UML resource page
Object Oriented System Design Class Diagrams
Chapter 11 Class Inheritance
UML  UML stands for Unified Modeling Language. It is a standard which is mainly used for creating object- oriented, meaningful documentation models for.
Computer Science II for Majors
Presentation transcript:

Inheritance Allows extension and reuse of existing code Derived class can access base class properties and still the derived class has its own properties

A generic Example

Inheritance in Railway Reservation System Passenger is a person Employee is a person E-ticket is a ticket I-ticket is a E-Ticket (Multi level Inheritance)

Look alike but exhibit different characters

Polymorphism Derived from the Greek many forms Single name can be used for different purposes Different ways of achieving the polymorphism: 1. Function overloading 2. Operator overloading 3. Dynamic binding

Polymorphism Languages exhibit polymorphism through operators "+" for addition of reals and integers or "-" for unary negation or arithmetic subtraction. Therefore the same operation is performed on different data types with out changing the basic meaning of the operation.  ‘*’ is overloaded for multiplication and as dereference operator

Static Vs Dynamic binding Routing a call to a landline/mobile phone Binding->Tie up of a call to the address code to be executed in response to a call Landline – Static routing Mobile Phones – Dynamic binding Behavior of the object determined only at runtime Also called as late binding

Polymorphism in Railway Reservation System Search a train – Search by train number, name etc – Function Overloading [], -, + - Operators shall be overloaded for knowing details of a coach in a train, add or remove a coach from a train

Polymorphism in Railway Reservation System ComputeSalary function shall be made as pure virtual function and implemented in dervied classes regular employee, daily wages employee etc

Message passing  Sending and receiving of information by the objects same as people exchange information Invoking an operation on an object To invoke an operation is based on the name of the operation and the class of the object being operated. Shall be interpreted as a request for the execution of a function.

Message Passing in Railway Reservation System Know the availability of seats in a coach during reservation Interaction is between the ticket object and the coach object Ticket makes a request and coach returns the availability

Persistance Phenomena by which object outlives the program execution and exists between executions of a program Not supported in C++

Delegation Receiving object may delegate operations to other objects Eg: Child class can delegate the request to parent class Age of a passenger Requested will be delegated to parent class - person

Genericity Defines the software with more than one interpretation depending on the data type of parameters Thus, it allows the declaration of data items without specifying their exact data type. Such data types are solved at the time of their usage. This can be realized through the “function template” and “class template”

Genericity in C++ Function templates – Sort coaches by capacity, by class (First, Second, third), coach position Class templates – Stack ADT, linked list, Queues etc

There are two kinds of Relationships OO Relationships There are two kinds of Relationships Generalization (parent-child relationship) Association (student enrolls in course) Associations can be further classified as Aggregation Composition

OO Relationships: Generalization Supertype Example: Customer Regular Customer Loyalty Customer Subtype1 Subtype2 or: Customer - Generalization expresses a parent/child relationship among related classes. - Used for abstracting details in several layers Regular Customer Loyalty Customer

OO Relationships: Association Represent relationship between instances of classes Student enrolls in a course Courses have students Courses have exams Coach is connected to a train Association has two ends Role names (e.g. enrolls, connected) Multiplicity (e.g. One course can have many students, one train may have many coached)

How to create the class “Account” in dia? accno:int acctype:String name:String balance:float deposit(a:int):void withdraw(a:int):int enquire():String

Choose the option “UML” From the select box

Select the class from the tool bar and Drag and drop it in to the canvas Select “class”

Double click the compartment “Class”

Edit the class name as “Account”

Now choose the Tabbed button “Attributes” to name the attribute

Press the button “New” to enable the “Attribute data” fields and edit the fields(name,type and visibility)

Now press the button “New” to add more attributes and finally press “ok”

Similarly, choose the Tabbed button “Operations” to add the operations Press “New” to enable the parameter data fields

Adding parameters and type and press ok

Use the same procedure to add other methods

A sample showing the “Association” relationship Double click the association link for setting the properties

A sample showing the generalization relationship