Declarative Layer Composition in Framework-based Environments Malte - - PowerPoint PPT Presentation

declarative layer composition in framework based
SMART_READER_LITE
LIVE PREVIEW

Declarative Layer Composition in Framework-based Environments Malte - - PowerPoint PPT Presentation

Declarative Layer Composition in Framework-based Environments Malte Appeltauer, Robert Hirschfeld Software Architecture Group Hasso-Plattner-Institute University of Potsdam Run-time Adaptation in Context-oriented Programming layer layer


slide-1
SLIDE 1

Declarative Layer Composition in Framework-based Environments

Malte Appeltauer, Robert Hirschfeld Software Architecture Group Hasso-Plattner-Institute University of Potsdam

slide-2
SLIDE 2

Run-time Adaptation in Context-oriented Programming

layer

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

control flow layer composition layer composition

slide-3
SLIDE 3

Framework

Problems

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

User Code

■ access to framework code prohibited ■ adaptation in third-party code requires deep knowledge ■ distracting from domain-related work

control flow layer composition layer composition layer composition layer composition

slide-4
SLIDE 4

Framework

Layer Composition can be a Crosscutting Concern

layer composition layer composition

User Code

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

layer composition layer composition layer composition

slide-5
SLIDE 5

Crosscutting Concerns

■ code □ homogeneous □ heterogeneous ■ adaptation

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

■ adaptation □ static / compile-time □ dynamic / run-time

slide-6
SLIDE 6

Crosscutting Concerns: Context-oriented Programming

■ code □ homogeneous □ heterogeneous ■ adaptation Classes Decomposition Runtime ■ adaptation □ static / compile-time □ dynamic / run-time

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

Layers C

slide-7
SLIDE 7

Crosscutting Concerns: Aspect-oriented Programming

■ code □ homogeneous □ heterogeneous ■ adaptation

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

■ adaptation □ static / compile-time □ dynamic / run-time

slide-8
SLIDE 8

Extending COP to New Application Domains

■ graphical user interfaces ■ mobile platforms ■ distributed systems ■ context-based applications

[ASH11]

■ context-based applications

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

[Appeltauer10] [AH08, AHR08] [AHM09, AHH+10, AHM+10] [RAL+11]

slide-9
SLIDE 9

A GUI-based Computer Game

■ action adventure computer game □ graphical user interface framework □ user-controlled character □ interaction with other entities □ interaction with other entities ■ heterogeneous crosscutting concerns □ confused character behavior □ graphics zooming □ development mode

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

slide-10
SLIDE 10

A GUI-based Computer Game Object-oriented Decomposition

EntityUI Entity KeyboardListener

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

Hero RegionUI Character AiCharacter Knight Princess World Region GameWindow WorldUI ImageProvider

slide-11
SLIDE 11

EntityUI Entity KeyboardListener

A GUI-based Computer Game Character Behavior

Hero RegionUI Character AiCharacter Knight Princess World Region GameWindow WorldUI ImageProvider

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

slide-12
SLIDE 12

KeyboardListener EntityUI Entity

A GUI-based Computer Game Character Behavior

Framework

hero confused? then compose layer hero confused? then compose layer if (hero.isConfused()) { with(ConfusedHeroLayer) { … } } Hero EntityUI RegionUI Entity Character AiCharacter Knight Princess World Region GameWindow WorldUI ImageProvider

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

hero confused? then compose layer hero confused? then compose layer

control flow

slide-13
SLIDE 13

KeyboardListener EntityUI Entity

A GUI-based Computer Game Character Behavior

Framework

hero confused? then compose layer hero confused? then compose layer

layer composition may be a

Hero EntityUI RegionUI Entity Character AiCharacter Knight Princess World Region GameWindow WorldUI ImageProvider

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer control flow

hero confused? then compose layer hero confused? then compose layer

  • meta-level
  • homogeneous

crosscutting concern

  • meta-level

aspect-oriented programming

slide-14
SLIDE 14

The JCop Programming Language

Decomposition Runtime

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

slide-15
SLIDE 15

The JCop Programming Language

■ Java language extension □ based on ContextJ ■ explicit language constructs for ■ explicit language constructs for □ layers □ partial methods □ explicit layer activation □ context classes

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

slide-16
SLIDE 16

The JCop Programming Language Context Class

■ meta-level aspect ■ encapsulates layer composition

public contextclass MagicBottleContext {

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

public contextclass MagicBottleContext { private Bottle bottle; private Layer confusedBehavior = new ConfusedHero(); public DrinkingContext(Bottle bottle) { this.bottle = bottle; } public boolean heroDrunkTheBottle() { return bottle.isEmpty(); } when(heroDrunkTheBottle()) : with(confusedBehavior); }

pointcut composition advice

slide-17
SLIDE 17

The JCop Programming Language Evaluation

ContextJ-based implementations JCop-based implementations refactoring to JCop

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

slide-18
SLIDE 18

The JCop Programming Language Evaluation

Case Studies Project Size (User Code) COP-based Layer Composition JCop-based Layer Composition implementation tangled classes implementation tangled classes RetroAdventure Computer Game

  • 33 Classes
  • 3 Layers
  • 3000 LoC

15 with statements 30% 3 context classes CJEdit

  • 40 Classes

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer

0% CJEdit GUI-based Text Editor

  • 40 Classes
  • 6 Layers
  • 3500 LoC

13 with statements 13% 2 context classes MyBook SOA-based Web Shop

  • 30 Classes
  • 6 Layers
  • 4500 LoC

10 with statements 24% 1 context class, JCop/SOA Library AstroPic Mobile Device Image Gallery

  • 9 Classes
  • 2 Layers
  • 320 LoC

3 with statements 33% 1 context class WhenToDo Context-based ToDoApplication

  • 25 Classes
  • 2 Layers
  • 1500 LoC

18 with statements 24% 1 context class, Context Query Library

slide-19
SLIDE 19

Summary

■ COP for framework-based environments □ layer composition may be a crosscutting concern □ redundant composition statements ■ using the JCop programming language □ integration of a meta-level aspect language for layer composition □ additional layer composition features (static, reflective, object-specific, implicit) ■ case study-based evaluation □ applications that use inversion of control □ mobile, event-based, service-oriented, context management systems

Declarative Layer Composition in Framework-based Environment, COP'12, 2012-06, M. Appeltauer