Polymorphism Chapter six of: Szyperski, Clemens et al. Component Software - Beyond Object-Oriented Programming. Second Edition.

Slides:



Advertisements
Similar presentations
CSE Winter 2008 Introduction to Program Verification refining an interface.
Advertisements

INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
CSE-321 Programming Languages Subtyping POSTECH May 14, 2007 박성우.
Lecture # 20 Type Systems. 2 A type system defines a set of types and rules to assign types to programming language constructs Informal type system rules,
Automated creation of verification models for C-programs Yury Yusupov Saint-Petersburg State Polytechnic University The Second Spring Young Researchers.
12. Summary, Trends, Research. © O. Nierstrasz PS — Summary, Trends, Research Roadmap  Summary: —Trends in programming paradigms  Research:...
Introduction to Java Kiyeol Ryu Java Programming Language.
Component-Based Software Engineering Components and Interfaces Paul Krause.
13. Summary, Trends, Research. © O. Nierstrasz PS — Summary, Trends, Research Summary, Trends, Research...  Summary: functional, logic and object-oriented.
1 Specifying Object Interfaces. 2 Major tasks in this stage: --are there any missing attributes or operations? --how can we reduce coupling, make interface.
Reasons to study concepts of PL
How is Java different from other languages Less than you think: –Java is an imperative language (like C++, Ada, C, Pascal) –Java is interpreted (like LISP,
OOP #10: Correctness Fritz Henglein. Wrap-up: Types A type is a collection of objects with common behavior (operations and properties). (Abstract) types.
12. Summary, Trends, Research. © O. Nierstrasz PS — Summary, Trends, Research Roadmap  Summary: —Trends in programming paradigms  Research:...
Software Testing and Quality Assurance
1 Type Type system for a programming language = –set of types AND – rules that specify how a typed program is allowed to behave Why? –to generate better.
1 A Short Introduction to (Object-Oriented) Type Systems Kris De Volder.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Component Technology objects versus components -- definitions interoperability.
Component Software Beyond Object-Oriented Programming Clements Szyperski Chapter 7 – Object versus class composition or how to avoid inheritance Alexandre.
C++ fundamentals.
Engr 691 Special Topics in Engineering Science Software Architecture Spring Semester 2004 Lecture Notes.
Programming Languages and Paradigms Object-Oriented Programming.
Programming C# in comparison to C++, Java and Smalltalk by Anne Holzapfel.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Ranga Rodrigo. The purpose of software engineering is to find ways of building quality software.
Design by Contract in Java Concept and Comparison.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
OOP Class Lawrence D’Antonio Lecture 3 An Overview of C++
1 COMP313A Programming Languages Object Oriented Progamming Languages (3)
COP4020 Programming Languages Names, Scopes, and Bindings Prof. Xin Yuan.
Types in programming languages1 What are types, and why do we need them?
Introducing Allors Applications, Tools & Platform.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
CBSE Component Based Software Engineering cs. upt
1 CSE 331 Generics (Parametric Polymorphism) slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Side effects A side effect is anything that happens in a method other than computing and/or returning a value. Example: public class hello { public int.
Chapter 1 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Semantic Analysis II Type Checking EECS 483 – Lecture 12 University of Michigan Wednesday, October 18, 2006.
CSCI-383 Object-Oriented Programming & Design Lecture 24.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Chapter 20 Concepts for Object-Oriented Databases Copyright © 2004 Pearson Education, Inc.
Types and Programming Languages Lecture 10 Simon Gay Department of Computing Science University of Glasgow 2006/07.
1 Lecture 8 b Data Structures b Abstraction b The “Structures” package b Preconditions and postconditions b Interfaces b Polymorphism b Vector class b.
Arrays Using array as an expression, on the right-hand side Assigning to an array.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
619 Final Review Last updated Fall 2011 Paul Ammann.
Subtying Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Compound Types for Java Object Oriented Systems and Languages © 2001 Marcus Handte.
ISBN Chapter 12 Support for Object-Oriented Programming.
CSC 520 – Advanced Object Oriented Programming, Fall, 2010 Thursday, September 30 Week 5, Generics and Inheritance Techniques, Meyer Ch. 10 & 16.
Page 1, CBSE – graduate course Specification of Software Components Frank Lüders Mälardalen University, Dept. of Computer Engineering
Component Object Model(COM)
Component Based Software Engineering
Specifying Object Interfaces
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Winter 2013.
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Spring 2016.
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Autumn 2018.
Seminarium on Component-based Software Engineering
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Autumn 2017.
619 Final Review Last updated Spring 2010 © : Paul Ammann.
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Zach Tatlock Winter 2018.
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Spring 2017.
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Spring 2013.
Drew Wyborski Programming Languages
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Spring 2019.
Presentation transcript:

Polymorphism Chapter six of: Szyperski, Clemens et al. Component Software - Beyond Object-Oriented Programming. Second Edition

Schedule  Concept  Substitutability  Types, subtypes, and type checking  Object languages and types  Types, interfaces, and components  The paradigm of independent extensibility  Safety by construction

Schedule  Module safety  Safety, security, trust

Concept “Polymorphism is the ability of something to appear in multiple forms, depending on context, and the ability of different things to appear the same in a certain context”

Substitutability  What a interface should require? What is essential for the service  A Client may establish more than is required by the precondition  A Provider may establish more than is required by the postcondition

Interface TextModel{ int max();//maximum length this text can have int length();//current length char read(int pos);//character at position pos void write(int pos, char ch);//insert character ch at position pos //[len: int; txt : array of char Pre len:=this.length();(all i:0  i<len: txt[i] := this.read(i)); len<this.max() and 0  pos  len Post this.length() = len + 1 and (all i:0  i<pos: this.read(i) = txt[i]) and this.read(pos) = ch and (all i:pos<i<this.length(): this.read(i) = txt[i-1]) //] }

Class GreatTextModel implements TextModel{... void write(int pos, char ch){ //[len: int; txt : array of char Pre len := this.length(); (all i:0  i<len: txt[i] := this.read(i)); len<this.max() and 0  pos < this.max() Post this.length() = max(len, pos) + 1 and (all i: 0  i < min(pos,len) : this.read(i) = txt[i]) and this.read(pos) = ch and (all i: pos < i  len: this.read(i) = txt[i-1]) and (all i: len < i < pos: this.read(i) = “ ”) //]... }.... }

Substitutability Clients InterfaceProviders Calls Results

Types, subtypes, and type checking  Chekings  Memory errors  Types: sets of all values of related semantics  Type Contexts  Types in Preconditions and Postconditions  Ways to form subtypes

Interface View{ void close(); void restore(int left, int top, int right, int bottom); } Interface TextView extends View{ int caretPos(); void setCaretPos(int pos); } Interface Graphics extends View{ int cursorX(); int cursorY(); void setCursorXY(int x, int y); }

Subtypes  Subcontract  Covariance and Contravariance Function F Function G

Object languages and types  No Explicit type system Smalltalk, Strongtalk Runtime checking  Explicit type system Java Compiler-time checking Narrowing type casts

Other forms of polymorphism  Overloading  Parametric polymorphism  Bounded polymorphism

Types, interfaces, and components  Interfaces  Type inference  Structural subtyping  Category Microsoft´s COM IDL

The paradigm of independent extensibility  A system is independently extensibility if it is extensible and if independently developed extensions can be combined (Szyperski,1996)  Applications and SOs are fragmented  Flexibility X Performance and robustness

Safety by construction  Viability of components  Examples: Java Component Pascal.Net

Module safety  A component has to specify explicitly which services it needs to access  Module safety is not simple  Reflection service  Metaprograming

Safety, security, trust  Type safety, module safety, and absence of memory errors may be not enough  Formal proofs  Sociological process

Extensions  Orthogonal  Bottleneck interfaces  Singleton  Parallel  Recursive

Evolution x immutability of interfaces and contracts  Interface  Specification