Object Oriented Design Lecture #4 – Inheritance, Interfaces, Classes Tomasz Pieciukiewicz.

Slides:



Advertisements
Similar presentations
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.
Advertisements

UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Chapter Object-Oriented Practices. Agenda Object-Oriented Concepts Terminology Object-Oriented Modeling Tips Object-Oriented Data Models and DBMSs.
Chapter 14 (Web): Object-Oriented Data Modeling
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 Class and Object Diagrams PRACTICAL OBJECT-ORIENTED DESIGN WITH.
Chapter 4: Object-Oriented Data Modeling
Object Oriented Concepts. Movement toward Objects Instead of data-oriented or process-oriented Analysis, many firms are now moving to object-oriented.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Object and Object- Relational Databases.
1 Object-Oriented Modeling Using UML CS 3331 Fall 2009.
Chapter 14: Object-Oriented Data Modeling
EER vs. UML Terminology EER Diagram Entity Type Entity Attribute
Introduction To System Analysis and design
Comparison of OO Programming Languages © Jason Voegele, 2003.
CS 403 – Programming Languages Class 25 November 28, 2000.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
Unified Modeling Language, Version 2.0
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
Object Orientation Yaodong Bi, Ph.D. Department of Computer Sciences University of Scranton October 18, 2015October 18, 2015October 18, 2015.
CHAPTER 13 (ONLINE): OBJECT-ORIENTED DATA MODELING © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
1 © Prentice Hall, 2002 Chapter 14: Object-Oriented Data Modeling Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R.
© 2011 Pearson Education 1 Chapter 13 (Online): Object-Oriented Databases Modern Database Management 10 th Edition, International Edition Jeffrey A. Hoffer,
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 13 (Online): Object-Oriented Data Modeling Modern Database Management 10 th Edition.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
Refactoring Deciding what to make a superclass or interface is difficult. Some of these refactorings are helpful. Some research items include Inheritance.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Object-Oriented Data Modeling
Object Oriented Analysis: Associations. 2 Object Oriented Modeling BUAD/American University Class Relationships u Classes have relationships between each.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
1 Class Diagrams. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are for visualizing, specifying and documenting.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Object Oriented Programming
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
1 Unified Modeling Language, Version 2.0 Chapter 2.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
The ODMG Standard for Object Databases
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Object Modeling THETOPPERSWAY.COM. Object Modelling Technique(OMT)  Building a model of an application domain and then adding implementation.
Variations on Inheritance Object-Oriented Programming Spring
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Polymorphism and Virtual Functions One name many shapes behaviour Unit - 07.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi © 2013 Pearson.
Class Relationships Lecture Oo08 Polymorphism. References n Booch, et al, The Unified Modeling Language User Guide, Chapt 10 p.125 n Fowler & Scott, UML.
Polymorphism Lecture - 9.
COMPUTER SCIENCE & TECHNOLOGY DEGREE PROGRAMME FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UVA WELLASSA ‏ Properties of Object Oriented Programming.
Chapter 4_part2: The Enhanced Entity-Relationship (EER) Model.
CSCE 240 – Intro to Software Engineering Lecture 3.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Polymorphism in Methods
UML Diagrams: Class Diagrams The Static Analysis Model
Object-Oriented Modeling
Some Simple Design Modeling Techniques
Sachin Malhotra Saurabh Choudhary
Object-Oriented Analysis and Design
Interface, Subclass, and Abstract Class Review
Systems Analysis and Design With UML 2
Inheritance and Polymorphism
Systems Analysis and Design With UML 2
Object-Oriented Programming
Object Oriented Programming in Java
Types of Programming Languages
Chapter 12 Outline Overview of Object Database Concepts
Object Oriented Analysis and Design
Inheritance Basics Programming with Inheritance
Computer Programming with JAVA
Software Design Lecture : 14.
Polymorphism CT1513.
Presentation transcript:

Object Oriented Design Lecture #4 – Inheritance, Interfaces, Classes Tomasz Pieciukiewicz

Agenda Inheritance Parametrized Classes Interfaces Attributes and Methods

INHERITANCE

Inheritance types disjont (default) overlapping complete incomplete (default)... (ellipsis)

Inheritance types Do not put default inheritance information on the diagram Tree OakBirchPine {disjoint, complete} species

Single-aspect inheritance Exchange area Pipe diameter Tank volume pressure Equipment type Pump type Tank type Specialization aspect Equipment name manufacturer cost Suction pressure Compression pressure flow Pump Heat exchanger

Single-aspect inheritance Equipment name manufacturer cost Suction pressure Compression pressure flow Exchange area Pipe diameter volume pressure Equipment type Suction pressure Compression pressure flow Exchange area Pipe diameter Tank volume pressure Equipment type Equipment name manufacturer cost PumpHeat Exchanger

Multi-aspect inheritance Vehicle {overlapping} Wind-powered Vehicle Engine-powered Vehicle Land Vehicle Water Vehicle propulsion terrain {overlapping} Two inheritance aspects: terrain and propulsion

Multi-inheritance Name Person Employed Student Employee Salary Student ID

Multi-inheritance: problems Vehicle {economy speed is 50% top speed} top_speed economy_speed() AmphibianCarYacht economy_speed() Water vehicleLand vehicle Name conflict: which top_speed attribute should be inherited by the amphibian? Does the economy_speed() method meaning depend on the inheritance path? (O2: mechanism for renaming of inherited properties; Eiffel: conflict treated as an error.)

Dynamic Inheritance Person Manager Engineer Salesman Female Male {mandatory} sex « dynamic » profession

Abstract Classes Abstract class can not have instances Defines common part of group of classes with similar semantics In UML marked with tagged value {abstract = TRUE} (=TRUE may be omitted) OR by writing the entity’s (class or method) name in italics. Concrete class – can have instances.

Abstract Classes Persona {abstract} Person Company Sequence first next Int sequence... implementation Char sequence... implementation

Abstract Methods Per-Hour Employee perHour holidaysHour noofHours noofHolidayHours calculateSalary Employee weeklySalary numberofweeks calculateSalary Contract Employee monthlySalary calculateSalary calculateSalary{abstract} Employee {abstract}

Abstract Methods Abstract method – specified in abstract class, implemented in subclasses Abstract class may have abstract methods, but does not have to Concrete class has to implement all inherited abstract methods not implemented in any superclass Concrete class can’t have abstract methods

PARAMETRIZED CLASSES

Parametrized Classes - notation Set Current parametrization parameter Set insert(T) delete(T) T EmployeeSet « bind » template

INTERFACES

Interfaces dependency Company realization Person {abstract} First name Last name Date of birth Calculate age Employee salary position Change salary IEmployee «interface» + Change salary

Interfaces Stereotype > Method specification, no implementation No attributes All methods are public Method implementation in class which realizes the interface Dependency – shows classes that use an interface

Interfaces Employee IEmployee Person Company The abstract class and interface were shown as interface definitions. Abstract classes – unlike interfaces – may contain attributes and method implementations

CLASS EXTENT

Class Extent Current set of all class instances. Implemented as a special data structure attached to the class. Some methods work on instances Some methods work on the class extent

Class Extent I set of direct (no sub-classes) instances of the given class II set of instances of the given class (direct and indirect), limited to the attributes specified in the given class III set of instances of the given class (direct and indirect)

ATTRIBUTES AND METHODS

Attributes  Simple  Complex  Optional [0..1]  Repeatable [x..y]  Derived (/name)  Class attributes  Object attributes

Methods  abstract  object  class methods

Method Overriding Method specification from specialized class overrides specification from general class Related with method polymorphism Requires dynamic binding Supports reuse Employee name... fire()... Manager fire()

Binding Process of replacing symbolic identifier (name) for value, address or internal entity identifier May be early or late

Early vs Late Binding Early (static) binding: during compilation and consolidation Pros: ◦ better performance, ◦ full static typechecking Cons: ◦ less flexible, ◦ No dynamic app extensions (plug-ins) Late (dynamic) binding: at runtime Pros: ◦ Method overriding ◦ Dynamic app extension (plug-ins) ◦ Rapid development Cons: ◦ Worse performance ◦ Difficult typechecking

Late Binding – why bother?  Polymorphism  Dynamic views  Dynamic stored procedures  Query languages  Object migration  Database schema evolution

Method overloading Symbol’s semantics depend on the context – e.g. number or type of arguments ◦ move (x,y) and move (x,y,z) ◦ move (int, int) and move (float, float) Some authors (e.g. Cardelli – evangelist of polymorphic types theory) believe that overloading is not a form of polymorphism ◦ All methods implementing an operation should have the same signature

QUESTIONS?