relation type theory foundations & applications. overview introduction type theory object type...

46
Relation Type Theory Foundations & Applications

Upload: louise-small

Post on 02-Jan-2016

221 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Relation Type Theory

Foundations & Applications

Page 2: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Overview

• Introduction• Type Theory• Object Type Theory– Critique of Object Type Theory– Patches for Object Type Theory

• Relation Type Theory– Applications• With Object Type Theory (Co-existence)• Without Object Type Theory (Standalone)

Page 3: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Introduction

• Methodology of Science• Contradictory Manifestos• Programming Paradigm Proliferation

Page 4: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Methodology of Science

Page 5: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Contradictory Manifestos

Page 6: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Programming Paradigm Proliferation

• Declarative– Functional– Logic– Constraint

• Imperative– Procedural– Object Oriented (and Subject Oriented)– Aspect Oriented– …

• But they are all based on Object Type Theory!

Page 7: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Type Theory

• What is a type?• Why do we need types?• What kind of types?• How are things bound to types?• How do types relate to each other?

Page 8: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

What is a Type? (wiktionary)• Type

– A grouping based on shared characteristics; a class. – […]– (computing theory) A tag attached to variables and values used

in determining what values may be assigned to what variables.

• Class– A group, collection, category or set sharing characteristics or

attributes. [..] Often used to imply membership of a large class.– […]– (computing) A set of objects possibly differing in state but not

behavior.

Page 9: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

What is a Type?

• A type is – a grouping – of things – based on some kind of commonality.

Page 10: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Why do we need Types?

• To define behavior for the– Creation– Destruction– Mutation– Assignment (special kind of Mutation)of the things we are grouping.

• It is all about SHARED BEHAVIOR!

Page 11: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

What kinds of types?

• Differentiate on the things that get grouped– things can be objects– things can be relations

• This gives us two kinds of types– Object Types– Relation Types

Page 12: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

How are things bound to types?

• Objects are a priori bound to types– objects are bound to one type– objects remain bound to this same type

• Relations are a posteriori bound to Types– relations are bound to a type based on rules– relations can be rebound if relations/rules change

Page 13: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

How do types relate to each other?

• Two kinds of type inheritance– Derivation by Extension

(OO Languages , XML Schema)– Derivation by Restriction

(Relational Model, XML Schema)

Page 14: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Kinds of Type Theory

• There are 2 kinds of Type Theory– Object Type Theory– Relation Type Theory

Page 15: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Object Type Theory

• No consensus, at least 2 competing camps– Object Oriented Model (OODBS Manifesto)– Relational Model (Third Manifesto)

• But from a Type Theory perspective, they are actually not that different!

Page 16: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Object Oriented Model (OODBS Manifesto)

• Defines mandatory and optional features that an OO Database System must support

• Most important are– Complex Objects– Object Identity

Page 17: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Complex Objects

Page 18: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Object Identity

Page 19: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Relational Model(Third Manifesto)

Page 20: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Relation-Valued Attributes

• The value of an attribute can be any type– So it can also be a Relation Type

• Closure of Relation Composition– Relations can contain other Relations (Relation-

Valued attributes) or scalar values.

Page 21: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Relational Algebra and Assignment

• Relations are immutable• Relation variables are mutable

• So all operations on relations are set based

Page 22: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Critique of Object Type Theory

• Object Types determine behavior– But relations actually determine behavior!

• Relations have different meaning– Relations are either set based or object based

• Type binding is too static• Relations are second (or third) rate citizens– Objects are ‘owners’ of relation endpoints

Page 23: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Object Types determine behavior

• But relations actually determine behavior!

Page 24: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Relations have different meaning

• Relations are either set based or object based

Page 25: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Type binding is too static

Page 26: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Relations are second rate citizens

Page 27: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Patches for Object Type Theory

• Design by Contract• State Machines (Finite Automata)• Aspect Oriented Programming• Subject Oriented Programming

Page 28: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Design By Contract

• Class invariants using Pre- and Post conditions

Page 29: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

State Machines

Page 30: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Aspect Oriented Programming

Page 31: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Subject Oriented Programming

Page 32: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Relation Type Theory• A Relation Type– is a type– that is a priori– statically bound– to a relation

• A Relations Type (Is this necessary?)– is a type – that is a posteriori – dynamically bound – to relations – based on rules about those relations– and that defines behavior for those relations

Page 33: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Applications

• Applications of Relations Type Theory– With Object Type Theory (Co-existence)• Relation Oriented Method Overloading• Multiple Type Declarations• 3rd Generation Object Oriented Programming (OOP)

– Without Object Type Theory (Standalone)• Relation Oriented Programming (ROP)

Page 34: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Relation Oriented Method Overloading

• Same signature, Different behavior

Page 35: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

RO Method Overloading - Advantages

• Extra level of polymorphism• More robust (contrary to Contract Based)

Page 36: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Multiple Type Declarations

• Definition• Advantages• Example• Implementation

Page 37: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Muldecs - Definition• A Multiple Type Declaration (muldec) is the

specification of a variables types– the objects assigned to the variable should implement

all types (usually interfaces)

• Muldecs can be supported at– The platform level (JVM, CLR, C++ linker …)– The language level (Java, C#, C++, …)– The framework level (Allors, …)

• Muldecs can be overloaded

Page 38: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Muldecs - Advantages

• Reduces the gap between statically and dynamically typed languages

• Less casting • Higher level of modularization– Looser coupling is possible

• Better evolution– More additive

• Especially suited for 3rd generation OOP

Page 39: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Muldecs - Example

Page 40: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Muldecs – Implementation in Allors

Page 41: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Muldecs - Notations

• C derivatives– type1 type2 … variable– methodName( type1 type2 … argument)

• Uml

Page 42: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

3rd Generation Object Oriented Programming (OOP)

• Can be seen as a evolution from– 1st Generation OOP (Inheritance)– 2nd Generation OOP (Delegation)

• Builds upon– Relation Oriented Method Overloading– Multiple Type Declaration

Page 43: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

1st Generation OOP

Page 44: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

2nd Generation OOP

Page 45: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

3rd Generation OO

Page 46: Relation Type Theory Foundations & Applications. Overview Introduction Type Theory Object Type Theory – Critique of Object Type Theory – Patches for Object

Relation Oriented Programming