OOP - Mod 3 - Inheritance, Lecture notes of Programming Paradigms

The concept of inheritance in object-oriented programming and how it relates to object families and hierarchies. It explains the idea of passing down characteristics from parent to child and how it plays an important part in object-oriented design and programming. The document also covers generalization and specification, classification, and the use of keywords for inheritance and superclass. It includes examples of inclusion or subtyping limitations and advantages of creating multiple objects.

Typology: Lecture notes

2020/2021

Available from 04/02/2022

gwen-hermo
gwen-hermo 🇵🇭

10 documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
OOP Mod 3
Inheritance
Object Families/Hierarchy
the idea of passing down characteristics from parent to child, and plays an
important part in Object-oriented design and programming.
Generalization/Specification
Classification hierarchic
o A person may be an employee, a customer or a supplier
o An employee may be paid monthly, weekly, or hourly
o An hourly-paid employee may be a driver, a cleaner, or a sales assistant
As you go up, more general. As you go down, more specific.
Keyword for inheritance
Keyword for superclass
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download OOP - Mod 3 - Inheritance and more Lecture notes Programming Paradigms in PDF only on Docsity!

Inheritance

Object Families/Hierarchy ➢ the idea of passing down characteristics from parent to child, and plays an important part in Object-oriented design and programming. Generalization/SpecificationClassification – hierarchic o A person may be an employee, a customer or a supplier o An employee may be paid monthly, weekly, or hourly o An hourly-paid employee may be a driver, a cleaner, or a sales assistant ➢ As you go up, more general. As you go down, more specific. ➢ Keyword for inheritance ➢ Keyword for superclass

Enumeration

Polymorphism

Object Polymorphism

  • Polymorphism - one of the benefits of Inheritance; poly – meaning many, and morphe – meaning form.
  • Inheritance lets us inherit attributes and methods from another class. Polymorphism uses those methods to perform different tasks. This allows us to perform a single action in different ways. - the use of a single symbol to represent multiple different types.
  • Major classes of polymorphism o Ad Hoc Polymorphism 1. Static polymorphism (Overloading) 2. Dynamic polymorphism (Overriding) o Inclusion Polymorphism – subtyping; a subtype is a datatype that is related to another datatype (the supertype) by some notion of substitutability - program elements, typically subroutines or functions,written to operate on elements of the supertype can also operate on elements of the subtype. o Parametric polymorphism - enables the generic definition of functions and types, without a great deal of concern for type-based errors. - way to make a language more expressive, while still maintaining full static type-safety.

EXAMPLES 2:

Inclusion or Subtyping Limitations : Employee cannot access to PartimeEmployee Objects Advantage: Create multiple objects

Parametric Polymorphism