magritte - portalscg.unibe.ch/download/mm/slides/02magritte.pdfmagritte squeakmap release 2006 2007...

46
Magritte www.lukas-renggli.ch Software Composition Group University of Bern [René Magritte, 1966] Decalcomania

Upload: others

Post on 21-Apr-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Magritte

www.lukas-renggli.ch

Software Composition Group

University of Bern

[René M

ag

ritt

e, 1966] D

ecalc

om

ania

Page 2: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

! Academics

– PhD Student, University of Bern

! Industry

– Independent Software Consultant

! Communities

– Core-developer of Seaside

– Author of Magritte and Pier

Lukas Renggli

Page 3: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Agenda

! Introduction and Example

! History and Usage

! Implementation Details

! Adaptive Models

Page 4: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

MagritteIntroduction and Example

Describe once,

Get everywhere

Page 5: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Address Object

street = 'Schützenmattstrasse'plz = 3012place = 'Bern'canton = 'Bern'

:Address

Page 6: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Address Class

street = 'Schützenmattstrasse'plz = 3012place = 'Bern'canton = 'Bern'

:Address

street: Stringplz: Integerplace: Stringcanton: String

Address

class

Page 7: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Address Description

street = 'Schützenmattstrasse'plz = 3012place = 'Bern'canton = 'Bern'

:Address

label = 'Street'

:StringDescription

label = 'PLZ'required = truerange = 1000..9999

:NumberDescription

label = 'Place'required = true

:StringDescription

label = 'Canton'required = truesorted = trueoptions = #( 'Bern' 'Zurich' ... )

:SingleOptionDescription

label = 'Address'

:Containerdescription

Page 8: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Address Description

street = 'Schützenmattstrasse'plz = 3012place = 'Bern'canton = 'Bern'

:Address

label = 'Street'

:StringDescription

label = 'PLZ'required = truerange = 1000..9999

:NumberDescription

label = 'Place'required = true

:StringDescription

label = 'Canton'required = truesorted = trueoptions = #( 'Bern' 'Zurich' ... )

:SingleOptionDescription

label = 'Address'

:Containerdescription

Magritte

Page 9: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Describe (1)

Address class>>#descriptionStreet

! ^ MAStringDescription new! ! autoAccessor: #street;! ! label: 'Street';! ! priority: 100;! ! yourself

Address class>>#descriptionPlz

! ^ MANumberDescription new! ! autoAccessor: #plz;! ! priority: 200;! ! label: 'PLZ';! ! beRequired;! ! min: 1000;! ! max: 9999;! ! yourself

Page 10: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Describe (2)

Address class>>#descriptionPlace

! ^ MAStringDescription new! ! autoAccessor: #place;! ! label: 'Place';! ! priority: 300;! ! beRequired;! ! yourself

Address class>>#descriptionCanton

! ^ MASingleOptionDescription new! ! options: #('Zuerich' 'Bern' 'Luzern' ...);! ! autoAccessor: #canton;! ! label: 'Canton';! ! priority: 400;! ! beRequired;! ! beSorted;! ! yourself

Page 11: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Interpret (1)

anAddress description do: [ :description | Transcript show: description label; show: ':'; tab; show: (description toString: (anAddress readUsing: description)); cr ]

Street:! Schutzenmattstrasse

PLZ:! 3012

Place:! Bern

Canton:! Bern

Page 12: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

result := anAddress asMorph! addButtons;! addWindow;! callInWorld

Interpret (2)

Page 13: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

result := self call: (anAddress asComponentaddValidatedForm;yourself).

Interpret (3)

*

*

*

Page 14: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

! Reflection

– Introspection

– Intercession

! Viewer building

! Editor building

! Report building

! Documentation

! Data validation

! Query processing

! Object filtering

! Object serialization

! Object copying

! Object indexing

! Object initialization

! Object verification

! Object adaption

! Object customization

and much more ...

What is it used for?

Page 15: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

! Describe once, get everywhere.

! Extensibility of classes is ensured.

! Context dependent descriptions.

! End-user customizable.

! Developer configurable.

Why is it useful?

Page 16: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Why is it cool?

! Describe once, get everywhere.

! Be more productive.

! Lower coupling.

! Empower your users.

! Do more, with less code.

! Do more, with less hacking.

Page 17: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

It seems a drag to me that you need to add 22 14 class

categories of Magritte, [...] I’d rather avoid Magritte. It’s a

PhD Master thesis, and so not optimized for simplicity.

People who use it, love it, I suppose. Probably makes

them feel smart.

— Chris Cunnington

Page 18: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

MagritteHistory and Usage

Describe once,

Get everywhere

Page 19: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

2003

2004

2005

2002

SmallWiki started as University Project

SmallWiki released

1st price inESUG Innovation

Technology Awards

Started with SmallWiki 2(meta-model based)

Changed development from VisualWorks to Squeak

Changed product name fromSmallWiki to Pier

ExtractedMagritte

SqueakMaprelease

2006

2007

2008

Magritte: Meta-Described

Web Application Development

Magritte: A Meta-Driven Approach to

Empower Developers and End Users

3rd price inESUG Innovation

Technology Awardsseaside.st

1st commercial Magritte Application

Magritte

on WikiPedia

Page 20: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven
Page 21: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven
Page 22: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Aare

Workflow definition

and runtime system

Page 23: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven
Page 24: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven
Page 25: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

MagritteImplementation Details

Describe once,

Get everywhere

Page 26: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Descriptions

! Problem

– Objects and their values all need to be treated

differently.

! Example

– Boolean and String are not polymorphic, therefore

different code for certain operations is necessary.

! Solution

– Introduce a descriptive hierarchy that can be

instantiated, configured and composed.

Page 27: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

[Yoder et al, 2001] Architecture and design of adaptive object models

Page 28: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) MagritteComponent

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

[Renggli et al, 2007] Magritte — A Meta-Driven Approach to Empower Developers and End Users

Page 29: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) MagritteComponent

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

[Renggli et al, 2007] Magritte — A Meta-Driven Approach to Empower Developers and End Users

Page 30: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) MagritteComponent

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

[Renggli et al, 2007] Magritte — A Meta-Driven Approach to Empower Developers and End Users

Page 31: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Descriptions

Composite pattern

to describe model-instances.

Description

Container ElementDesc.children

StringDesc. BooleanDesc.

Accessor Condition

Page 32: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Descriptions

Description

Container ElementDesc.

ColorDesc. MagnitudeDesc. StringDesc. ReferenceDesc.

DateDesc. NumberDesc. OptionDesc. RelationDesc.

ToOneDesc. ToManyDesc.SingleDesc. MultipleDesc.

children

BooleanDesc.

reference

Page 33: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Accessors

! Problem

– Data can be stored and accessed in different ways.

! Examples

– Accessor methods, chains of accessor methods,

instance-variables, dictionaries, derived values,

external values, etc.

! Solution

– Provide a strategy pattern to be able to access data

through a common interface.

Page 34: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Accessor

Cascade Selector Dictionary

Auto

Block Null

next, accessor

Strategy pattern

to access model-entities.

Accessors

Page 35: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

o: Object d: Description a: Accessor

readUsing: d

accessor

read: o

write: v using: d

accessor

write: v to: o

<strategy a>

<strategy a>

Page 36: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Mementos

! Problems

– Editing might turn a model (temporarily) invalid.

– Canceling an edit shouldn’t change the model.

– Concurrent edits of the same model should be

detected and (manually) merged.

! Solution

– Introduce mementos that behave like the original

model and that delay modifications until they are

committed.

Page 37: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Memento pattern

to cache model-entities.

Memento

Strait Cached

Checked

ObjectDescriptiondescription model

Dictionary

Dictionary

cache

original

Mementos

Page 38: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

MagritteAdaptive Models

Describe once,

Get everywhere

Page 39: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Rapidly changing

requirements

Page 40: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Adaptive

Model

Description

Object

+ copy()d

escrip

tio

ns

valu

es

Page 41: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

End users would

know their requirements

Page 42: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) MagritteComponent

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

Component

TypeComponent

Property

TypeProperty

1 *

1

*

*1

*

1

Type Object

Type Object

(a) Type-Square

Object

Description

Typ

e

Ob

ject

*

*

descrip

tio

n

attributes

1 *

(b) Magritte

[Renggli et al, 2007] Magritte — A Meta-Driven Approach to Empower Developers and End Users

Page 43: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Domain Model

Metamodel

Meta-Metamodel

<described-by>

<described-by>

Developer

End User

Page 44: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Domain Model

Metamodel

Meta-Metamodel

MagritteDeveloper

<described-by>

<described-by>

MagritteEnd User

Page 45: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Demo

Page 46: Magritte - Portalscg.unibe.ch/download/mm/Slides/02Magritte.pdfMagritte SqueakMap release 2006 2007 2008 Magritte: Meta-Described Web Application Development Magritte: A Meta-Driven

Conclusion

! Describe once, get everywhere.

! Ensure extensibility and maintainability.

! Automate repetitive tasks.

! End-user customizability.

! (Run-time) adaptive object model.