Chair of Software Engineering OOSC - Lecture 21 1 Object-Oriented Software Construction Bertrand Meyer.

Slides:



Advertisements
Similar presentations
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 5.
Advertisements

SCOOP: Simple Concurrent Object-Oriented Programming Extend the pure, strongly typed, object-oriented language Eiffel with a general and powerful concurrency.
Eiffel: Analysis, Design and Programming Bertrand Meyer (Nadia Polikarpova) Chair of Software Engineering.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Exercise Session 1: Eiffel Introduction.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 7: References and Assignment.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 3: Abstract Data Types.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session November 2008.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 7: SCOOP Type System (based on work with Piotr Nienaltowski)
Chair of Software Engineering PPoPP 2003, , San Diego SCOOP it up! Piotr Nienaltowski Chair of Software Engineering, ETH Zurich, Switzerland.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering ATOT - Lecture 25, 30 June Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering OOSC Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Bertrand Meyer Object-Oriented Software Construction Lecture 8: More on inheritance.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 15: Exception handling.
Chair of Software Engineering ATOT - Lecture 24, 25 June Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering Piotr Nienaltowski, , Concurrent Object-Oriented Programming Bertrand Meyer, Piotr Nienaltowski.
Chair of Software Engineering Object-Oriented Software Construction Bertrand Meyer Lesson 21 Last update: 25 May 2004 Type issues, covariance and catcalls.
Chair of Software Engineering Piotr Nienaltowski, , Concurrent Object-Oriented Programming Bertrand Meyer, Piotr Nienaltowski.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 10: Project Presentation Ilinca.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering ATOT - Lecture 12, 12 May Advanced Topics in Object Technology Bertrand Meyer.
Principles of Object-Oriented Software Development The language Eiffel.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 6: Object Creation.
Chair of Software Engineering ATOT - Lecture 8, 28 April Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering OOSC Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Lecture 4 1 Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering ATOT - Lecture 9, 30 April Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Covariance & anchored types 2 Covariance? Within the type system of a programming language, a typing rule or a type conversion operator is*:
Chair of Software Engineering ATOT - Lecture 25, 30 June Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 9: Contracts and Inheritance (based on work with.
Slide 1 Chapter 3 Attribute Grammars. Slide 2 Attribute Grammars Certain language structures cannot be described using EBNF. Attribute grammars are extensions.
Eiffel: Analysis, Design and Programming Bertrand Meyer Chair of Software Engineering.
Chair of Software Engineering ATOT - Lecture 23, 23 June Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering ATOT - Lecture 20, 11 June Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 6: Genericity.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 6: Object Creation.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 10.
Chair of Software Engineering OOSC - Summer Semester Bertrand Meyer Object-Oriented Software Construction Lecture 7: Inheritance.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 5.
Chair of Software Engineering Object-Oriented Software Construction Bertrand Meyer Lecture 21: Agents and tuples.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 7.
Chair of Software Engineering ATOT - Lecture 7, 23 April Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering ATOT - Lecture 22, 18 June Advanced Topics in Object Technology Bertrand Meyer.
1 Genericity Parameterizing by Type. 2 Generic Class One that is parameterized by type  Works when feature semantics is common to a set of types On object.
Comparison of OO Programming Languages © Jason Voegele, 2003.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
Eiffel Naeem Esfahani University of Tehran "Man cannot discover new oceans unless he has the courage to lose sight of the shore." -- Andre Gide.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Contracts for Concurrency - Contracts & Inheritance Aryabrata Basu University of Georgia.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session October 2008.
Genericity Ranga Rodrigo Based on Mark Priestley's Lectures.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session October 2008.
Ceg860 (Prasad)L17IT1 Inheritance Techniques Subcontracting Anchored Types.
DBC NOTES. Design By Contract l A contract carries mutual obligations and benefits. l The client should only call a routine when the routine’s pre-condition.
CSCI 383 Object-Oriented Programming & Design Lecture 22 Martin van Bommel.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Chair of Software Engineering Void safety these slides contain advanced material and are optional.
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Einführung in die Programmierung Introduction to Programming Prof. Dr
Einführung in die Programmierung Introduction to Programming Prof. Dr
Einführung in die Programmierung Introduction to Programming Prof. Dr
Presentation transcript:

Chair of Software Engineering OOSC - Lecture 21 1 Object-Oriented Software Construction Bertrand Meyer

Chair of Software Engineering OOSC - Lecture 21 2 Lecture 21: Typing issues, covariance

Chair of Software Engineering OOSC - Lecture 21 3 The America Conjecture (Pierre America at TOOLS Europe 1990)  One can have at most two of the three properties of:  Static typing.  Substitutivity.  Covariance.  Can we disprove the America conjecture?

Chair of Software Engineering OOSC - Lecture 21 4 Typing: A simple problem!  The basic operation of object-oriented computation: x.f (arg)

Chair of Software Engineering OOSC - Lecture 21 5 The typing problem  When, and how, do we know that:  There is a feature applicable to OBJ and corresponding to f?  arg is an acceptable argument for that feature?

Chair of Software Engineering OOSC - Lecture 21 6 Terminology x: Entity. OBJ: The object attached to x at some time during execution. f: Routine (One of the two forms of feature; the other is attributes.) xOBJ

Chair of Software Engineering OOSC - Lecture 21 7 Typing vs. binding  What do we know about the feature to be called?  Static typing: At least one  Dynamic binding: The right one  Example: my_aircraft.lower_landing_gear

Chair of Software Engineering OOSC - Lecture 21 8 Inheritance and typing AIRCRAFT * PLANE * COPTER * BOEINGAIRBUS A_320 B_747B_737 B_747_400 * deferred + effected ++ redefined lower_landing_gear* lower_landing_gear++ lower_landing_gear+

Chair of Software Engineering OOSC - Lecture 21 9 Cost of correcting errors (Boehm) RequirementsDesignCodeDevelopmentAcceptanceOperation test SMALL PROJECTS LARGE PROJECTS

Chair of Software Engineering OOSC - Lecture Typing rules (all locally checkable)  Declaration rule.  Call rule.  Attachment rule.  (For the precise formulations see Eiffel: The Language.)

Chair of Software Engineering OOSC - Lecture Declaration rule  Every entity must be declared as being of a certain type.  For example: x: AIRCRAFT n: INTEGER ba1: BANK_ACCOUNT

Chair of Software Engineering OOSC - Lecture Call rule  If a class C contains the call x.f  there must be a feature of name f in the base class of the type of x, and that feature must be available (exported) to C.

Chair of Software Engineering OOSC - Lecture Attachment rule  In an assignment x := y, or the corresponding argument passing, the base class of the type of y must be a descendant of the base class of the type of x.

Chair of Software Engineering OOSC - Lecture For typing to be acceptable  No exception to type ee-rules (“casts”).  Multiple inheritance  Unconstrained genericity: class LIST [G]...  Constrained genericity: class VECTOR [G –> NUMERIC]...

Chair of Software Engineering OOSC - Lecture For typing to be acceptable (cont’d)  Assignment attempt: x ?= y  Contracts, to clarify the semantics and include constraints other than typing (e.g. numerical ranges).  Covariance for routine arguments.  Anchored declarations (like x) to avoid endless redeclarations.

Chair of Software Engineering OOSC - Lecture Multiple inheritance DOCUMENTMESSAGE MAILABLE_ DOCUMENT

Chair of Software Engineering OOSC - Lecture A class hierarchy DRIVER BIKER TRUCKER HEAVY_TRUCKER partner: DRIVER share (other: DRIVER) partner++ share++ partner++ share++ partner++ share++

Chair of Software Engineering OOSC - Lecture Choosing a partner class DRIVER feature partner: DRIVER -- This driver’s alternate share (other: DRIVER) is -- Choose other as alternate. require other /= Void do partner := other end... end

Chair of Software Engineering OOSC - Lecture d1, d2: DRIVER... d1.share (d2) A typical call

Chair of Software Engineering OOSC - Lecture Specializing class TRUCKER inherit DRIVER redefine partner end feature partner: TRUCKER -- This driver’s alternate.... end

Chair of Software Engineering OOSC - Lecture The need for covariance class TRUCKER inherit DRIVER redefine partner, share end feature partner: TRUCKER -- This driver’s alternate. share (other: TRUCKER) is -- Choose other as alternate. require other /= Void do partner := other end end

Chair of Software Engineering OOSC - Lecture Direct covariance DRIVER BIKER TRUCKER HEAVY_TRUCKER partner: DRIVER share (other: DRIVER) partner++ share++ partner++ share++ partner++ share++

Chair of Software Engineering OOSC - Lecture  Anchored declarations: class TRUCKER inherit DRIVER redefine partner, share end feature partner: TRUCKER -- This driver’s alternate. share (other: like partner) is -- Choose other as alternate. require other /= Void do partner := other end end Avoiding redefinition avalanche

Chair of Software Engineering OOSC - Lecture End of lecture 22