Docsity

Object-Oriented Design: Generalization, Specialization, Inheritance, and Polymorphism, Slides of Object Oriented Analysis and Design

Partial preview of the text

Download Object-Oriented Design: Generalization, Specialization, Inheritance, and Polymorphism and more Slides Object Oriented Analysis and Design in PDF only on Docsity!

Department of Computer Engineering

Sharif University of Technology

Object-Oriented Design

Lecturer: Raman Ramsin

Lecture 9:

Generalization/Specialization

Department of Computer Engineering

Sharif University of Technology

Analysis Workflow: Analyze a Use Case  The analysis workflow consists of the following activities:  Architectural analysis  Analyze a use caseOutputs:analysis classesuse case realizations  Analyze a class  Analyze a package

Department of Computer Engineering

Sharif University of Technology

Generalization/Specialization  Generalization hierarchies may be created by generalizing from specific things or by specializing from general things.

Department of Computer Engineering

Sharif University of Technology

Inheritance  Class inheritance is implicit in a generalization relationship between classes.  The subclass inherits the following features from its parents - attributes, operations, relationships, and constraints.

Department of Computer Engineering

Sharif University of Technology

Abstract Operations and Classes  Abstract operations are designed to have no implementation:  they serve as placeholders;  all concrete subclasses must implement all inherited abstract operations.  An abstract class has one or more abstract operations:  abstract classes can't be instantiated;  abstract classes define a contract as a set of abstract operations that concrete subclasses must implement.

Department of Computer Engineering

Sharif University of Technology

Abstraction Level  all things at the same level in a generalization hierarchy should be at the same level of abstraction.

Department of Computer Engineering

Sharif University of Technology

Polymorphism: Example

Department of Computer Engineering

Sharif University of Technology

Polymorphism: Concrete Operations  Polymorphic operations have more than one implementation:  different classes may implement the same polymorphic (abstract/concrete) operation differently;  polymorphism allows instances of different classes to respond to the same message in different ways.

Department of Computer Engineering

Sharif University of Technology

Generalization Sets: Implementation

Department of Computer Engineering

Sharif University of Technology

Generalization Sets: Example