relation type theory foundations & applications. overview introduction type theory object type...
TRANSCRIPT
Relation Type Theory
Foundations & Applications
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)
Introduction
• Methodology of Science• Contradictory Manifestos• Programming Paradigm Proliferation
Methodology of Science
Contradictory Manifestos
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!
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?
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.
What is a Type?
• A type is – a grouping – of things – based on some kind of commonality.
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!
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
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
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)
Kinds of Type Theory
• There are 2 kinds of Type Theory– Object Type Theory– Relation Type Theory
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!
Object Oriented Model (OODBS Manifesto)
• Defines mandatory and optional features that an OO Database System must support
• Most important are– Complex Objects– Object Identity
Complex Objects
Object Identity
Relational Model(Third Manifesto)
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.
Relational Algebra and Assignment
• Relations are immutable• Relation variables are mutable
• So all operations on relations are set based
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
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 rate citizens
Patches for Object Type Theory
• Design by Contract• State Machines (Finite Automata)• Aspect Oriented Programming• Subject Oriented Programming
Design By Contract
• Class invariants using Pre- and Post conditions
State Machines
Aspect Oriented Programming
Subject Oriented Programming
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
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)
Relation Oriented Method Overloading
• Same signature, Different behavior
RO Method Overloading - Advantages
• Extra level of polymorphism• More robust (contrary to Contract Based)
Multiple Type Declarations
• Definition• Advantages• Example• Implementation
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
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
Muldecs - Example
Muldecs – Implementation in Allors
Muldecs - Notations
• C derivatives– type1 type2 … variable– methodName( type1 type2 … argument)
• Uml
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
1st Generation OOP
2nd Generation OOP
3rd Generation OO
Relation Oriented Programming