Chapter 2 Lesson 4: Modeling Relationship Among Classes - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Chapter 2 Lesson 4: Modeling Relationship Among Classes

Description:

Class diagrams used to model static Structures of Object-Oriented Software ... Other examples: blender, car, bike, etc. Code: Java, Classes gets implemented. Interface ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 14
Provided by: FordhamUn5
Category:

less

Transcript and Presenter's Notes

Title: Chapter 2 Lesson 4: Modeling Relationship Among Classes


1
Chapter 2 Lesson 4 Modeling Relationship Among
Classes
  • Inheritance

2
Last Time
  • Classes
  • Objects
  • Message Passing
  • Modularity
  • Abstraction
  • Encapsulation
  • Polymorphism

3
Modeling Relationship and Structures
  • Class diagrams used to model static Structures of
    Object-Oriented Software Systems and relationship
    among classes
  • Class diagrams consists of
  • A set of nodes that represent classes and
    interfaces
  • A set of links that represent relationships among
    classes

4
Relationship that can Modeled using Class Diagrams
  • Inheritance, including extension and
    implementation
  • Association, including aggregation and
    composition
  • Dependency

5
Inheritance
  • Inheritance defines a relationship among classes
    and interfaces.
  • There a several forms of inheritance
    relationship
  • Extension relation between two classes. When
    class C2 extends class C1, class C2 is known as a
    subclass of class C1, and class C1 is known as a
    superclass of class C2
  • The extension relationship between two
    interfaces. When interface I2 extends interface
    I1, interface I2 is known as a subinterface of
    interface I1, interface I1 is known as a
    superinterface of interface I2

6
Inheritance
  • The implementation relationship between a class
    and an interface. When class C2 implements
    interface I1, class C2 is known as an
    implementation of interface I1

7
Inheritance
Interface
  • The implementation relationship between a class
    and an interface. When class C2 implements
    interface I1, class C2 is known as an
    implementation of interface I1
  • Other examples blender, car, bike, etc.

Code Java, Classes gets implemented
8
UML Terminology for Inheritance
  • Specialization ? Extension
  • Generalization ? the inverse of specialization
  • Realization ? Implementation

9
Graphical Representation of Inheritance
Superclass
Superinterface
Interface
Subclass
Subinterface
Implementation
Extension Of interfaces
Implementation of Interfaces
Extension of classes
10
Graphical Representation of Inheritance
  • Extension relationship solid line
  • Implementation relationship dashed line
  • In class diagrams
  • Regular class, fields methods Regular Roman
    fonts Example TriangleClass
  • Interface and methods in italic fonts

11
Conceptual Model of Inheritance
  • Inheritance Models the is-a(n) relationship in
    the real world, i.e., if C2 is a
    subclass/subinterface/implementation of C1, then
    every instance of C1 is an instance of C2, and
    everything that applies to instances of C1 also
    applies to instances of C2
  • Extension relationship between classes commonly
    associated with notion of reusing or sharing the
    implementation (i.e., fields and methods) of the
    superclass by its subclass

12
Class Diagram Inheritance Relation Among Classes
Representing U.S Government
U.S. Government
Congress
Executive
Judicial
Senate
House
13
Inheritance Levels of Abstraction
  • Superclass represents more general abstractions
  • Subclasses Represents more specialized
    abstraction
Write a Comment
User Comments (0)
About PowerShow.com