V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for...

31
V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić [email protected] Department of Computer Science and Engineering Faculty of Electrical Engineering and Information Technology Slovak University of Technology in Bratislava

Transcript of V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for...

Page 1: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

V. Vranić — AspectJ Paradigm Model — GCSE 2001

AspectJ Paradigm Model

A Basis for Multi-Paradigm Design for AspectJ

Valentino Vranić [email protected]

Department of Computer Science and Engineering

Faculty of Electrical Engineering and Information Technology

Slovak University of Technology in Bratislava

Page 2: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

2V. Vranić — AspectJ Paradigm Model — GCSE 2001

Presentation Overview

• Multi-paradigm design• Feature modeling• Multi-paradigm design with feature modeling• AspectJ paradigm model• Transformational analysis• An example: Text editing buffers• Conclusions

Page 3: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

3V. Vranić — AspectJ Paradigm Model — GCSE 2001

Multi-Paradigm Design (MPD)

• MPD for C++ (J. O. Coplien)• Programming paradigms:– Large-scale paradigms– Small-scale paradigms

• Scope, commonality, variability, and relationship (SCVR) analysis

• Transformational analysis

Page 4: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

4V. Vranić — AspectJ Paradigm Model — GCSE 2001

Family table (from solution domain SCVR analysis)

Transformational Analysis in MPD

Parameters of Variation Meaning Domain Binding Default

BindingCommonality Variability Instantiation Language Mechanism

P1

Generalization of P1

(values P1 can take)

(default value for P1)

Variability tables (from application domain SCVR analysis)Domain D1 (main commonality of D1)

Page 5: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

5V. Vranić — AspectJ Paradigm Model — GCSE 2001

Feature Modeling• A conceptual modeling technique

c

f1 f2 f3 f4

f5 f6 f7

Feature diagrams– directed trees with edge

decorations– root = concept,

other nodes = features– common and variable

features– variation points

Other information– Semantic description– Rationale– Constraints– Default dependency

rules– Binding mode– Instantiation

Page 6: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

6V. Vranić — AspectJ Paradigm Model — GCSE 2001

MPD with Feature Modeling

• Feature models instead of tables and informal description

• Both feature modeling and SCVR analysis are based on commonalities and variabilities

• SCVR analysis and feature modeling:– scope concept– commonality common feature– variability variable feature– relationship feature diagrams hierarchy

Page 7: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

7V. Vranić — AspectJ Paradigm Model — GCSE 2001

Family table

MPD and

MPD with Feature Modeling

Parameters of Variation Meaning Domain Binding Default

variation pointsemantic description, rationale

alternative features

binding mode

default dependency rules

Variability table

Domain D1 (main commonality of D1 concept)

BindingCommonality Variability Instantiation Language Mechanism

common feature

binding mode

variable feature

additional information

concept

Page 8: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

8V. Vranić — AspectJ Paradigm Model — GCSE 2001

AspectJ Paradigm Model

Class

Overloading

inner fields Methods

type value

… … [run time]

Interface

constants declarations of Methods

Aspect

Advices Introductions fields Methods inner

[compile time]

type value

… … [run time]

Inheritance

base type implements

subtype

extends

Class Interface Aspect

Class Interface Aspect

AspectJ

Aspect Interface Class Inheritance

Page 9: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

9V. Vranić — AspectJ Paradigm Model — GCSE 2001

AspectJ Paradigm Model: Class Paradigm

Class

Overloading

inner fields Methods

type value

… … [run time]

Method

return value arguments static

non-static type value

… …

type value

… … [run time] [run time]

body

… static: [source time] non-static: [run time]

Overloading

name of Method

arguments of Method

body of Method

number type

return value

… [compile time]

Page 10: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

10V. Vranić — AspectJ Paradigm Model — GCSE 2001

AspectJ Paradigm Model: Aspect Paradigm

Aspect

Advices Introductions fields Methods inner

[compile time]

type value

… … [run time]

Advice

before

static join points dynamic join points

pointcut after around context

[run time] [compile time] … …

Introduction

types

Classes Interfaces

field Method

… … [compile time]

Page 11: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

11V. Vranić — AspectJ Paradigm Model — GCSE 2001

Transformational Analysis

• Prerequisites:– Solution domain feature model– Application domain feature model

• Matching of application domain feature model nodes with the solution domain feature model nodes– Points to the paradigms to be used for application

domain structures– Two nodes match if they conceptually represent the

same thing

Page 12: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

12V. Vranić — AspectJ Paradigm Model — GCSE 2001

Matching the Nodes

1. Select a node F from the application domain feature model

2. Try to match F’s children with the children of some node P that represents a paradigm in the solution domain feature model

3. If a match has been found for all of the F’s children, then F matches with P

4. A paradigm that represented by P should be used to implement feature F

Page 13: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

13V. Vranić — AspectJ Paradigm Model — GCSE 2001

The Process of Transformational Analysis

• Find the matching for all of the nodes in the application domain feature model

• Try to match the application domain nodes with the paradigms of “higher order” — the paradigms based on other paradigms (inheritance and overloading in AspectJ)

• Translate the results of the transformational analysis into the code:– directly– through a specific design method pointed to by MPD

Page 14: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

14V. Vranić — AspectJ Paradigm Model — GCSE 2001

An Example: Text Editing Buffers

• Represent a state of a file being edited• Employ different working set management

schemes• Use different character sets• Load and save the contents into a file• Maintain a record of the number of lines and

characters, cursor position, etc.

Page 15: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

15V. Vranić — AspectJ Paradigm Model — GCSE 2001

File read

write

status

name

contents

Unix File

read

write

database

read

write

ASCII

UNICODE

Character Set

yield data

replace data

load file

save file

Debugging Code debug

production

File DC

Character Set DC

Working Set Management DC

whole file yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

cursor position

number of characters

number of lines

Text Editing Buffer

Page 16: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

16V. Vranić — AspectJ Paradigm Model — GCSE 2001

Text Editing Buffer Text Editing Buffer

File read

write

status

name

contents

Unix File

read

write

database

read

write

ASCII

UNICODE

Character Set

yield data

replace data

load file

save file

Debugging Code debug

production

File DC

Character Set DC

Working Set Management DC

whole file yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

Class

Overloading

inner fields Methods

type value

… … [run time]

cursor position

number of characters

number of lines

cursor position

number of characters

number of lines

yield data

replace data

load file

save file

Page 17: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

17V. Vranić — AspectJ Paradigm Model — GCSE 2001

File read

write

status

name

contents

Unix File

read

write

database

read

write

ASCII

UNICODE

Character Set

Debugging Code debug

production

File DC

Character Set DC

Working Set Management DC

whole file yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

cursor position

number of characters

number of lines

yield data

replace data

load file

save file Method

return value arguments static

non-static type value

… …

type value

… … [run time] [run time]

body

… static: [source time] non-static: [run time]

read

statusname

contents

File

write

statusname

contents

Text Editing Buffer

Page 18: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

18V. Vranić — AspectJ Paradigm Model — GCSE 2001

File read

write

status

name

contents

Unix File

read

write

database

read

write

ASCII

UNICODE

Character Set

yield data

replace data

Debugging Code debug

production

File DC

Character Set DC

Working Set Management DC

whole file yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

cursor position

number of characters

number of lines

yield data

replace data

load file

save file Method

return value arguments static

non-static type value

… …

type value

… … [run time] [run time]

body

… static: [source time] non-static: [run time]

read

write read

write

read

write

Text Editing Buffer

Page 19: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

19V. Vranić — AspectJ Paradigm Model — GCSE 2001

File

status

name

contents

Unix File

database

ASCII

UNICODE

Character Set

load file

save file

Debugging Code debug

production

File DC

Character Set DC

Working Set Management DC

whole file yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

cursor position

number of characters

number of lines

yield data

replace data

load file

save file read

write read

write

read

write

Unix File

database

File

name

contents

status

Class

Overloading

inner fields Methods

type value

… … [run time]

Text Editing Buffer

Page 20: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

20V. Vranić — AspectJ Paradigm Model — GCSE 2001

ASCII

UNICODE

Character Set

Debugging Code debug

production

File DC

Character Set DC

Working Set Management DC

whole file yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

cursor position

number of characters

number of lines

yield data

replace data

load file

save file read

write read

write

read

write

Unix File

database

File

name

contents

status

Inheritance

base type implements

subtype

extends

Class Interface Aspect

Class Interface Aspect

Text Editing Buffer

Page 21: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

21V. Vranić — AspectJ Paradigm Model — GCSE 2001

ASCII

UNICODE

Character Set

Debugging Code debug

production

File DC

Character Set DC

Working Set Management DC

whole file yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

cursor position

number of characters

number of lines

cursor position

number of characters

number of lines

yield data

replace data

load file

save file read

write read

write

read

write

Unix File

database

File

name

contents

status

Inheritance

base type implements

subtype

extends

Class Interface Aspect

Class Interface Aspect

ASCII

UNICODE

Character Set

Text Editing Buffer

Page 22: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

22V. Vranić — AspectJ Paradigm Model — GCSE 2001

Debugging Code debug

production

File DC

Character Set DC

Working Set Management DC

whole file

yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

cursor position

number of characters

number of lines

yield data

replace data

load file

save file read

write read

write

read

write

Unix File

database

File

name

contents

status

ASCII

UNICODE

Character Set

whole file

yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

Inheritance

base type implements

subtype

extends

Class Interface Aspect

Class Interface Aspect

Text Editing Buffer

Page 23: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

23V. Vranić — AspectJ Paradigm Model — GCSE 2001

Debugging Code debug

production

File DC

Character Set DC

Working Set Management DC

cursor position

number of characters

number of lines

yield data

replace data

load file

save file read

write read

write

read

write

Unix File

database

File

name

contents

status

Inheritance

base type implements

subtype

extends

Class Interface Aspect

Class Interface Aspect

ASCII

UNICODE

Character Set

whole file

yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

Text Editing Buffer

Page 24: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

24V. Vranić — AspectJ Paradigm Model — GCSE 2001

Debugging Code debug

production

File DC

Character Set DC

Working Set Management DC

cursor position

number of characters

number of lines

yield data

replace data

load file

save file read

write read

write

read

write

Unix File

database

File

name

contents

status

ASCII

UNICODE

Character Set

whole file

yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

Debugging Code

Character Set DC

File DC

debug

production

Advice

before

static join points dynamic join points

pointcut after around context

[run time] [compile time] … …

Aspect

Advices Introductions fields Methods inner

[compile time]

type value

… … [run time]

Text Editing Buffer

Page 25: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

25V. Vranić — AspectJ Paradigm Model — GCSE 2001

Working Set Management DC

cursor position

number of characters

number of lines

yield data

replace data

load file

save file read

write read

write

read

write

Unix File

database

File

name

contents

status

ASCII

UNICODE

Character Set

whole file

yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

Debugging Code

Character Set DC

File DC

debug

production

Inheritance

base type implements

subtype

extends

Class Interface Aspect

Class Interface Aspect

whole file

Working Set Management DC

whole page

LRU fixed

Text Editing Buffer

Page 26: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

26V. Vranić — AspectJ Paradigm Model — GCSE 2001

cursor position

number of characters

number of lines

yield data

replace data

load file

save file read

write read

write

read

write

Unix File

database

File

name

contents

status

ASCII

UNICODE

Character Set

whole file

yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

Debugging Code

Character Set DC

File DC

debug

production

Working Set Management DC

Text Editing Buffer

Inheritance

base type implements

subtype

extends

Class Interface Aspect

Class Interface Aspect

Page 27: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

27V. Vranić — AspectJ Paradigm Model — GCSE 2001

cursor position

number of characters

number of lines

yield data

replace data

load file

save file read

write read

write

read

write

Unix File

database

File

name

contents

status

ASCII

UNICODE

Character Set

whole file

yield data

replace data

whole page

LRU fixed

yield data replace data

yield data

replace data

Working Set Management

Debugging Code

Character Set DC

File DC

debug

production

Working Set Management DC

Text Editing Buffer

• Feature diagrams alone do not fully determine the code skeleton

• What other sources are there?

Variability dependency graphs

Other information in feature model

Page 28: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

28V. Vranić — AspectJ Paradigm Model — GCSE 2001

Variability Dependency Graph

Text Editing Buffer

FileCharacter

Set

Debugging Code

Working Set Management

Page 29: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

29V. Vranić — AspectJ Paradigm Model — GCSE 2001

class TextBuffer {public: yield(...) {...}; replace(...) {...};

loadFile(...) {...}; saveFile(...) {...};

private: int numLines, numChars, curPosition;. . .}

class WholeFileTextBuffer extends TextBuffer {public: WholeFileTextBuffer(File f, CharacterSet c) {...};

yield(...) {...}; replace(...) {...};. . .}. . .

Page 30: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

30V. Vranić — AspectJ Paradigm Model — GCSE 2001

class File {public: Status readFile(String name, TextBuffer buff) {...} Status writeFile(String name, TextBuffer buff) {...} . . .}

class UnixFile extends File {. . .}. . .

aspect DebuggingCode {. . .}

aspect WorkingSetDebug extends DebuggingCode {. . .}

aspect WholeFileDebug extends WorkingSetDebug {. . .}. . .

Page 31: V. Vranić — AspectJ Paradigm Model — GCSE 2001 AspectJ Paradigm Model A Basis for Multi-Paradigm Design for AspectJ Valentino Vranić vranic@elf.stuba.sk.

31V. Vranić — AspectJ Paradigm Model — GCSE 2001

Conclusions

A new representation for the solution and application domain in MPD– Based on feature modeling– Involves a new transformational analysis

AspectJ paradigm model

• Further research:– Noting of the transformational analysis results– Incorporating the MPD’s negative variability tables

and variability dependency graphs– Relationship between the MPD and generative

programming