1 formal specification of o-o software architecture amnon h. eden tel aviv university and ericsson...

28
1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd Nordic Workshop on Software Architecture -- NOSA’99

Upload: horace-hodge

Post on 05-Jan-2016

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

1

Formal Specification of O-O Software Architecture

Amnon H. EdenTel Aviv University and Ericsson Research

Yoram HirshfeldTel Aviv University

The 2nd Nordic Workshop on Software Architecture -- NOSA’99

Page 2: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

2

Contents

Problem: Informal Specifications– Existing Solutions and their flaws

Two Separate contributions– Observations

– Specification language

Applications– Proofs on relations between patterns

– Tool support

Page 3: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

3

Elements of O-O Architecture

Different abstraction levels– Architecture

• Models: Layered Architecture, Client-Server, ...

– Design• Design Patterns (or rather, the abstraction of their solutions)

– Programming• Classes, objects, methods• Interactions

Page 4: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

4

Reminder: Design Pattern

abstract-factory

factory-1

factory-2

factory-n. . .

Page 5: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

5

Specification of Architecture

Existing means are:– Informal specifications (natural language)

• Ambiguous• Lead to confusions, debates• Prevent tool support, e.g., automated validation

– Specific examples• Not general• Programming language idiosyncrasy

Problem!

Page 6: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

6

Wanted: A Formal Specification Language

Desired properties:– Formal, precise

• Delivering accurate and unambiguous specifications

– Expressive• Can account for models in existence

– Concise• Easy to use and read

– Promote tool support• Formulae implemented easily

Page 7: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

7

Existing Solutions I

Allan & Garlan [94, 97]; Garlan & Shaw– Specification of dynamic invariants

– Extending process calculi (CSP)

– Flaws:• Focus on behavior, not on the static structure• Little relevance to OOP, no mapping to OOP constructs• Implementation is not trivial• Complete verification is often impossible• Validation requires separate run-time agents

Page 8: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

8

Existing Solutions II

Extensions of -Calculus – Specification of the semantics of OOP programs

• E.g.: System-F with subtyping (also F<:), Cardeli, Mitchell

– Flaws:• Wrong abstraction level: Elements of programs• Inexpressive

– Operational semantics

• Hard to prove properties, reason, implement

Page 9: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

9

Existing Solutions III

Pattern specification languages– E.g.: Mikkonen [98], Bosch [96], Lauder & Kent

[98]

– Focus on the Gang of Four catalog

– Flaws: • Not concise• Require language extension• Do not account for the observations made• Inexpressive

Page 10: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

10

Two Separate Contributions

Observations: Recurring motifs in O-O architecture– Building blocks for design patterns– Sets, correlations, isomorphisms

LePUS: A specification language– Express the building blocks– Calculus for combining them– Calculus for relations between patterns– Formal, expressive, concise, promote tool support– With a graphic equivalent

Page 11: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

11

Observations

Recurring motifs in O-O Architecture

Building blocks & correlations

Page 12: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

12

Sets

Uniform collections

Motif-window

Windows 95-window

PM -window

window

PM -creator

Windows 95 -creator

Motif-creator

Creator

Page 13: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

13

Sets of Sets: Classes

Windows95-Window-factory-

method(pos)

Motif-Window-factory-

method(pos)

PM -Window-factory-

method(pos)

Motif-window

Windows 95 -window

PM -window

PM -creator

Windows 95 -creator

Motif-creator

defined-in

defined-in

defined-in

Windows95-button-

factory-method

Motif-button-factory-method

PM -button-factory-method

Motif-button

Windows 95 -button

PM -button

defined-in

Page 14: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

14

Sets of Sets: Methods

Windows95-Window-factory-

method(pos)

Motif-Window-factory-

method(pos)

PM -Window-factory-

method(pos)

Motif-window

Windows 95 -window

PM -window

PM -creator

Windows 95 -creator

Motif-creator

defined-in

defined-in

defined-in

Windows95-button-

factory-method

Motif-button-factory-method

PM -button-factory-method

Motif-button

Windows 95 -button

PM -button

defined-in

Page 15: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

15

defined-in

)PM -

window-creator

Windows95-Window-creator

Motif-window-creator

defined-in

defined-in

Isomorphisms I

Windows95-Window-factory-method

Motif-Window-factory-method (pos)

PM2-Window-factory-method (pos)

Motif-window

Windows95-window

PM -

window

Page 16: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

16

Isomorphisms II

Windows95-Window-factory-

method(pos)

Motif-Window-factory-

method(pos)

PM -Window-factory-

method(pos)

Motif-window

Windows 95 -window

PM -window

PM -creator

Windows 95 -creator

Motif-creator

defined-in

defined-in

defined-in

Windows95-button-

factory-method

Motif-button-factory-method

PM -button-factory-method

Motif-button

Windows 95 -button

PM -button

defined-in

Page 17: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

17

Class Hierarchies

Page 18: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

18

LePUS

Ground Variables Ground Relations

Set VariablesSet Relations

Page 19: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

19

Computation Model

Program: Model (“structure”) describing a collection of entities and relations

Pattern: A set of constraints – Distinguishes which programs conform

Specification Language: A compact subset of higher order monadic logic

Page 20: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

20

Variables

Ground Variables:

Set Variables:

Hierarchies:

cls-varfnc-varfnc-var F, cls-var C

fuc-setF, cls-setCcls-setfnc-set

Creators ProductsCreators ä, Products 2ä

Page 21: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

21

Relations I

Ground Relations

factory-method

product

creator

Defined-In(factory-method, creator)

Return-Type(factory-method, product)

Creates(factory-method, product)

Page 22: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

22

Relations II

Isomorphisms

factory-method

product

creator

Defined-In(factory-method, creator)

Return-Type(factory-method, product)

Creates(factory-method, product)

Page 23: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

23

Abstract Factory

Creators

Factory-Methods

ProductsProducts

Graphic version

Textual version

Variables declaration

Isomorphisms

Commutativity

Page 24: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

24

Applications

Reasoning With Patterns

Tool Support

Page 25: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

25

Reasoning: Refinement

When is pattern p1 a “special-case-of” p2? The Multicast vs. Observer Debate

– Authors cannot agree if Multicast is a special case of Observer.

• Reported in: “Multicast”, John Vlissides. C++ Report, Sep. 97. SIGS Publications.

Solution: Define Refinement– Given the formulae , , we say that refines iff

.

Page 26: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

26

Refinement (continue)

subject

Observers

Update(subject )

attach(observers )

detach(observers )

notify

concrete-subject

get-state

Set-State

Observer (existing)

Messages

Receivers

receive(Messages)

Senders

multicast

Registry

register(Receivers)

Multicast (proposal)

Messages

Receivers

receive(Messages )

Senders

multicast

Typed Message (final)

Multicast (Refinement) Typed Message

Page 27: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

27

Reasoning: Projection

Hitherto unobserved relation Intuitively:

– Pattern occurs as an unbounded set in

Example:

Creators

Factory-Methods

ProductsProducts

Abstract Factory

Products

Creators

factory-methods

Products

Factory Method

Page 28: 1 Formal Specification of O-O Software Architecture Amnon H. Eden Tel Aviv University and Ericsson Research Yoram Hirshfeld Tel Aviv University The 2nd

28

Tool Support

Automating:– Validation

– Application

– Recognition

– (?) Discovery

Implementation in PROLOG

FactoryMethod(hierarchy_structure (Creators_root, Creators_Leaves), hierarchy_structure (Products_root, Products_Leaves), FactoryMethods) :- clan(FactoryMethods,[Creators_root|Creators_Leaves]), isomorphic(production, FactoryMethods, [Products_root|Products_Leaves]).

FactoryMethod(hierarchy_structure (Creators_root, Creators_Leaves), hierarchy_structure (Products_root, Products_Leaves), FactoryMethods) :- clan(FactoryMethods,[Creators_root|Creators_Leaves]), isomorphic(production, FactoryMethods, [Products_root|Products_Leaves]).