context-oriented programming for adaptive software systems · context-oriented programming (cop)...

69
Context-Oriented Programming for Adaptive Software Systems Tetsuo Kamina (Ritsumeikan University)

Upload: others

Post on 04-Jul-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Context-Oriented Programming for Adaptive Software Systems

Tetsuo Kamina (Ritsumeikan University)

Page 2: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Outline

Short introduction to context-oriented programming(COP)

ServalCJ: our achievement in COP language

Our position & vision for context-oriented software engineering (COSE)

Discussion on applying COP & COSE to adaptive software systems

2

Page 3: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Context-Oriented Programming (COP)[Costanza05, Hirschfeld08]

New programming paradigm for modularizing context-dependent behaviorPromising for context-aware systems

e.g. conference guide system

3

Networkavailable

Network unavailable

Program: Online, Local cacheTwitter: Available, Unavailable

consistency?modularity?

complexity?

local cache

Page 4: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Context-Oriented Programming (COP)[Costanza05, Hirschfeld08]

New programming paradigm for modularizing context-dependent behaviorPromising for context-aware systems

e.g. conference guide system

3

Map: City map, Floor planPositioning: GPS, Wi-Fi

Outdoors

Indoors

consistency?modularity?

complexity?

Page 5: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Context-Oriented Programming (COP)[Costanza05, Hirschfeld08]

New programming paradigm for modularizing context-dependent behaviorPromising for context-aware systems

e.g. conference guide system

3

Map: City map, Floor planPositioning: GPS, Wi-Fi

Outdoors

Indoors

Supporting foreseeable dynamic

changes in behavior and modularized systems

structure

consistency?modularity?

complexity?

Page 6: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 20154

Linguistic Constructs for COP

LayerModularizing context-dependent behaviorLightweight alternative to AOP/FOP

Layer activationSpecifying the scope of effect of layers

layer Outdoors { class Display { void display() {..}} class Position { void getPos() {..}} }

layer Indoors { class Display { void display() {..}} class Position { void getPos() {..}} }

d.display();

p.getPos();

Page 7: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 20154

Linguistic Constructs for COP

LayerModularizing context-dependent behaviorLightweight alternative to AOP/FOP

Layer activationSpecifying the scope of effect of layers

layer Outdoors { class Display { void display() {..}} class Position { void getPos() {..}} }

layer Indoors { class Display { void display() {..}} class Position { void getPos() {..}} }

d.display();

p.getPos();

Page 8: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 20154

Linguistic Constructs for COP

LayerModularizing context-dependent behaviorLightweight alternative to AOP/FOP

Layer activationSpecifying the scope of effect of layers

layer Outdoors { class Display { void display() {..}} class Position { void getPos() {..}} }

layer Indoors { class Display { void display() {..}} class Position { void getPos() {..}} }

d.display();

p.getPos();

Page 9: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 20154

Linguistic Constructs for COP

LayerModularizing context-dependent behaviorLightweight alternative to AOP/FOP

Layer activationSpecifying the scope of effect of layers

layer Outdoors { class Display { void display() {..}} class Position { void getPos() {..}} }

layer Indoors { class Display { void display() {..}} class Position { void getPos() {..}} }

d.display();

p.getPos();

syntax? semantics?

Page 10: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

Page 11: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

control-flow specificactivation

with (Outdoors) { .. }

Page 12: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

control-flow specificactivation

activation byexternal event

with (Outdoors) { .. } outdoors indoors

Page 13: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

control-flow specificactivation

activation byexternal event global

with (Outdoors) { .. } outdoors indoors

Page 14: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

control-flow specificactivation

activation byexternal event global

per-instance

with (Outdoors) { .. } outdoors indoors

Page 15: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

control-flow specificactivation

activation byexternal event global

per-instance

with (Outdoors) { .. } outdoors indoors

Each use case may coexist inone single application

Page 16: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

control-flow event-basedper-thread

global

control-flow specificactivation

activation byexternal event global

per-instance

with (Outdoors) { .. } outdoors indoors

Each use case may coexist inone single application

Page 17: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

control-flow event-basedper-thread

globalLanguage A

control-flow specificactivation

activation byexternal event global

per-instance

with (Outdoors) { .. } outdoors indoors

Each use case may coexist inone single application

Page 18: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

control-flow event-basedper-thread

globalLanguage A

Language B

control-flow specificactivation

activation byexternal event global

per-instance

with (Outdoors) { .. } outdoors indoors

Each use case may coexist inone single application

Page 19: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

control-flow event-basedper-thread

globalLanguage A

Language BNot covered!

Not covered!

control-flow specificactivation

activation byexternal event global

per-instance

with (Outdoors) { .. } outdoors indoors

Each use case may coexist inone single application

Page 20: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our motivation for new COP language

Several activation mechanisms for specific use cases

Just a combination is not sufficient

5

control-flow event-basedper-thread

globalLanguage A

Language BNot covered!

Not covered!

control-flow specificactivation

activation byexternal event global

per-instance

Activation mechanism beyond existing COP is required

with (Outdoors) { .. } outdoors indoors

Each use case may coexist inone single application

Page 21: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our achievement: ServalCJ[Kamina15, presented in MODULARITY'15]

Generalizing layer activation mechanismsContexts: duration of activation

Subscribers: the activation targetsCan be any sets of instances, whole application, and particular threads

6

T. Kamina et al., Generalized Layer Activation Mechanism through Contexts and Subscribers, In MODULARITY'15.

Page 22: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our achievement: ServalCJ[Kamina15, presented in MODULARITY'15]

Generalizing layer activation mechanismsContexts: duration of activation

Subscribers: the activation targetsCan be any sets of instances, whole application, and particular threads

activate Outdoors if(m.isProviderEnabled(m.GPS_PROVIDER))

6

T. Kamina et al., Generalized Layer Activation Mechanism through Contexts and Subscribers, In MODULARITY'15.

Page 23: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our achievement: ServalCJ[Kamina15, presented in MODULARITY'15]

Generalizing layer activation mechanismsContexts: duration of activation

Subscribers: the activation targetsCan be any sets of instances, whole application, and particular threads

activate Outdoors if(m.isProviderEnabled(m.GPS_PROVIDER))

Name of Layer

6

T. Kamina et al., Generalized Layer Activation Mechanism through Contexts and Subscribers, In MODULARITY'15.

Page 24: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our achievement: ServalCJ[Kamina15, presented in MODULARITY'15]

Generalizing layer activation mechanismsContexts: duration of activation

Subscribers: the activation targetsCan be any sets of instances, whole application, and particular threads

activate Outdoors if(m.isProviderEnabled(m.GPS_PROVIDER))

Name of Layer

Condition specifying when the layer is active(including control-flows and temporal terms)

6

T. Kamina et al., Generalized Layer Activation Mechanism through Contexts and Subscribers, In MODULARITY'15.

Page 25: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

No methods to elicit and model context-dep. behavior

Problem: lack of methodology

requirementselicitation modeling implementation

traditionalapproaches

use COP lang.

7

Page 26: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

No methods to elicit and model context-dep. behavior

Problem: lack of methodology

requirementselicitation modeling implementation

traditionalapproaches

use COP lang.

When we should use layers instead of design patterns?

7

Page 27: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

No methods to elicit and model context-dep. behavior

Problem: lack of methodology

requirementselicitation modeling implementation

traditionalapproaches

use COP lang.

When we should use layers instead of design patterns?

Requirements level contexts are vague•outdoors, indoors are contexts ... why?•the ID of the user is not a context ... why not?

7

Page 28: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

No methods to elicit and model context-dep. behavior

Problem: lack of methodology

requirementselicitation modeling implementation

traditionalapproaches

use COP lang.

When we should use layers instead of design patterns?

Requirements level contexts are vague•outdoors, indoors are contexts ... why?•the ID of the user is not a context ... why not?

Traceability?

7

Page 29: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Our vision

Presenting our preliminary study on COSE [Kamina14, presented in MODULARITY'14]]

Principles for finding context-dependent behaviorUse-case-driven method based on those principlesA case study

Overview of the whole development process will lead us to further research on each stage of development process

8

Page 30: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Principles

Factors for dynamically changing behavior that exist outside the behavior are candidates for contexts

Each such factor is a variable for a Boolean formula, which forms a context

If multiple variations of behavior share the same context, they should be implemented by using a layer

9

Page 31: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Overview of COSEIdentifying contexts and context-dependent use cases

Identifying layers by grouping use cases

Identifying layer activation by refining definition of contexts

description ofbehavior

contexts

context-dependentuse cases

outdoors indoors

city map

outdoors

...

outdoors

...

outdoorsLayer

outdoors GPSAvailable && !WifiAvailable decompositionLocationManager.isProviderEnabled( LocationManager.GPS_PROVIDER) == true

code-levelspecification

10

Page 32: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Identifying contexts

•Twitter is available only when the Internet is available•The user accesses the online program only when the Internet is available• If the user is inside the venue, the system displays a floor plan•The system can determine the position only when at least one positioning device

is available

11

Page 33: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Identifying contexts

Identifying candidates for Boolean variables, which will be used to define contexts•Twitter is available only when the Internet is available•The user accesses the online program only when the Internet is available• If the user is inside the venue, the system displays a floor plan•The system can determine the position only when at least one positioning device

is available

11

Page 34: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Identifying contexts

Identifying candidates for Boolean variables, which will be used to define contexts•Twitter is available only when the Internet is available•The user accesses the online program only when the Internet is available• If the user is inside the venue, the system displays a floor plan•The system can determine the position only when at least one positioning device

is available Find factors that change behavior(※conditions existing outside the behavior)

11

Page 35: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Identifying contexts

Identifying candidates for Boolean variables, which will be used to define contexts•Twitter is available only when the Internet is available•The user accesses the online program only when the Internet is available• If the user is inside the venue, the system displays a floor plan•The system can determine the position only when at least one positioning device

is available Find factors that change behavior(※conditions existing outside the behavior)

hasNetwork

indoors

hasPositioning

11

Page 36: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Identifying contexts

Identifying candidates for Boolean variables, which will be used to define contexts

Refining variables to make them orthogonal

•Twitter is available only when the Internet is available•The user accesses the online program only when the Internet is available• If the user is inside the venue, the system displays a floor plan•The system can determine the position only when at least one positioning device

is available Find factors that change behavior(※conditions existing outside the behavior)

hasNetwork

indoors

hasPositioning

outdoors

hasPositioningdepends

11

Page 37: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Identifying contexts

Identifying candidates for Boolean variables, which will be used to define contexts

Refining variables to make them orthogonal

•Twitter is available only when the Internet is available•The user accesses the online program only when the Internet is available• If the user is inside the venue, the system displays a floor plan•The system can determine the position only when at least one positioning device

is available Find factors that change behavior(※conditions existing outside the behavior)

hasNetwork

indoors

hasPositioning

outdoors

hasPositioningdepends

outdoorsindoors

cannotDecide

11

Page 38: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Identifying contexts

Identifying candidates for Boolean variables, which will be used to define contexts

Refining variables to make them orthogonal

•Twitter is available only when the Internet is available•The user accesses the online program only when the Internet is available• If the user is inside the venue, the system displays a floor plan•The system can determine the position only when at least one positioning device

is available Find factors that change behavior(※conditions existing outside the behavior)

hasNetwork

indoors

hasPositioning

outdoors

hasPositioningdepends

outdoorsindoors

!outdoors && !indoors

11

Page 39: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Defining context-dependent use cases

Annotating use cases that are applicable in specific contexts (Boolean terms)

Using a map <<include>> Moving

Viewing theprogram Using Twitter

12

Page 40: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Defining context-dependent use cases

Annotating use cases that are applicable in specific contexts (Boolean terms)

Using a map

Using a citymap

Using afloor plan

Using astatic map

outdoorsindoors!outdoors && !indoors

<<include>> Moving

Viewing theprogram Using Twitter

12

Page 41: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Defining context-dependent use cases

Annotating use cases that are applicable in specific contexts (Boolean terms)

Using a map

Using a citymap

Using afloor plan

Using astatic map

outdoorsindoors!outdoors && !indoors outdoors

<<include>> Moving

Moving whenoutdoors

Viewing theprogram Using Twitter

12

Page 42: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Defining context-dependent use cases

Annotating use cases that are applicable in specific contexts (Boolean terms)

Using a map

Using a citymap

Using afloor plan

Using astatic map

outdoorsindoors!outdoors && !indoors outdoors

<<include>> Moving

Moving whenoutdoors

Viewing theprogram Viewing online

program

hasNetwork

Using Twitter

12

Page 43: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Defining context-dependent use cases

Annotating use cases that are applicable in specific contexts (Boolean terms)

Using a map

Using a citymap

Using afloor plan

Using astatic map

outdoorsindoors!outdoors && !indoors outdoors

<<include>> Moving

Moving whenoutdoors

Viewing theprogram Viewing online

program

hasNetwork

Using Twitter

hasNetwork

12

Page 44: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Grouping use cases

Using a map

Using a citymap

Using afloor plan

Using astatic map

outdoorsindoors!outdoors && !indoors outdoors

<<include>> Moving

Moving whenoutdoors

Viewing theprogram Viewing online

program

hasNetwork

Using Twitter

hasNetwork

13

Page 45: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Grouping use cases

Use cases sharing the same contexts are identified as a layer

Using a map

Using a citymap

Using afloor plan

Using astatic map

outdoorsindoors!outdoors && !indoors outdoors

<<include>> Moving

Moving whenoutdoors

Viewing theprogram Viewing online

program

hasNetwork

Using Twitter

hasNetwork

13

Page 46: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Grouping use cases

Use cases sharing the same contexts are identified as a layer

Using a map

Using a citymap

Using afloor plan

Using astatic map

outdoorsindoors!outdoors && !indoors outdoors

<<include>> Moving

Moving whenoutdoors

Viewing theprogram Viewing online

program

hasNetwork

Using Twitter

hasNetwork

13

Page 47: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Grouping use cases

Use cases sharing the same contexts are identified as a layerSibling use cases of a layer are also layers

Using a map

Using a citymap

Using afloor plan

Using astatic map

outdoorsindoors!outdoors && !indoors outdoors

<<include>> Moving

Moving whenoutdoors

Viewing theprogram Viewing online

program

hasNetwork

Using Twitter

hasNetwork

13

Page 48: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Deriving layer activation

After designing classes and some implementation details, contexts in ServalCJ are derived...

Assuming Android SDK...

hasNetwork

HasNetwork(ConnectivityManager cm) : cm.getActiveNetworkInfo().getDetailedState() == NetworkInfo.DetailedState.CONNECTED

14

Page 49: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Deriving layer activation

After designing classes and some implementation details, contexts in ServalCJ are derived...

Assuming Android SDK...

hasNetwork

HasNetwork(ConnectivityManager cm) : cm.getActiveNetworkInfo().getDetailedState() == NetworkInfo.DetailedState.CONNECTED

expression using Android SDK

14

Page 50: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Deriving layer activation

After designing classes and some implementation details, contexts in ServalCJ are derived...

Assuming Android SDK...

hasNetwork

HasNetwork(ConnectivityManager cm) : cm.getActiveNetworkInfo().getDetailedState() == NetworkInfo.DetailedState.CONNECTED

outdoors

expression using Android SDK

14

Page 51: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Deriving layer activation

After designing classes and some implementation details, contexts in ServalCJ are derived...

Assuming Android SDK...

hasNetwork

HasNetwork(ConnectivityManager cm) : cm.getActiveNetworkInfo().getDetailedState() == NetworkInfo.DetailedState.CONNECTED

outdoors GPSAvailable && !VenueWifiAvailable

expression using Android SDK

decomposed as

14

Page 52: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Deriving layer activation

After designing classes and some implementation details, contexts in ServalCJ are derived...

Assuming Android SDK...

hasNetwork

HasNetwork(ConnectivityManager cm) : cm.getActiveNetworkInfo().getDetailedState() == NetworkInfo.DetailedState.CONNECTED

outdoors GPSAvailable && !VenueWifiAvailable

expression using Android SDK

decomposed as

not inside the venue

14

Page 53: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Deriving layer activation

After designing classes and some implementation details, contexts in ServalCJ are derived...

Assuming Android SDK...

hasNetwork

HasNetwork(ConnectivityManager cm) : cm.getActiveNetworkInfo().getDetailedState() == NetworkInfo.DetailedState.CONNECTED

outdoors GPSAvailable && !VenueWifiAvailable

LocationManager.isProviderEnabled( LocationManager.GPS_PROVIDER) == true

expression using Android SDK

decomposed as

not inside the venue

14

Page 54: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Context-dependent behavior crosscutting multiple classes

class Program ... { public void onCreate() { .. .. } public void loadCalendar() { .. .. .. .. } public void onClick() { .. .. } .. ..}

class MainActivity ... { public void onCreate() { .. .. .. .. .. } public void startUpScheduler() { .. .. .. .. .. .. .. } public void startUpTwitter() { .. .. .. } public void onStart() { .. .. .. } ..}

class Map ... { public Intersection onStart() { .. .. ..

} public int onLocationChanged() { .. .. .. .. .. } public void onProviderEnabled() { .. ..

} public void onProviderDisabled() { .. .. ..

} ..

..}

Class structure of the system

15

Map.java Main.java

Program.java

Outdoors

HasNetwork

Indoors

Page 55: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Context-dependent behavior crosscutting multiple classes

class Program ... { public void onCreate() { .. .. } public void loadCalendar() { .. .. .. .. } public void onClick() { .. .. } .. ..}

class MainActivity ... { public void onCreate() { .. .. .. .. .. } public void startUpScheduler() { .. .. .. .. .. .. .. } public void startUpTwitter() { .. .. .. } public void onStart() { .. .. .. } ..}

class Map ... { public Intersection onStart() { .. .. ..

} public int onLocationChanged() { .. .. .. .. .. } public void onProviderEnabled() { .. ..

} public void onProviderDisabled() { .. .. ..

} ..

..}

Class structure of the system

15

Map.java Main.java

Program.java

OutdoorsHasNetwork

Indoors

Page 56: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

class Program ... { public void onCreate() { .. .. } public void loadCalendar() { .. .. .. .. } public void onClick() { .. .. } .. ..}

class MainActivity ... { public void onCreate() { .. .. .. .. .. } public void startUpScheduler() { .. .. .. .. .. .. .. } public void startUpTwitter() { .. .. .. } public void onStart() { .. .. .. } ..}

class Map ... { public Intersection onStart() { .. .. ..

} public int onLocationChanged() { .. .. .. .. .. } public void onProviderEnabled() { .. ..

} public void onProviderDisabled() { .. .. ..

} ..

..}

15

Map.java Main.java

Program.java

OutdoorsHasNetwork

Indoors

Control of layer activationglobal contextgroup CtxCtl(ConnectivityManager cm) { activate HasNetwork if(cm.getActiveNetworkInfo().getDetailedState() == NetworkInfo.DetailedState.CONNECTED); context GPSAvailable is if(LocationManager.isProviderEnabled( LocationManager.GPS_PROVIDER) == true); context VenueWifiAvailable is if(C.isWifiConnected()); activate Outdoors when GPSAvailable && not(when VenueWifiAvailable); activate Indoors when VenueWifiAvaileble && if(C.isWifiPosAllowed());}

- Derived in the previous slide- Specified separately from the base program

Page 57: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

What COSE supports

requirementselicitation modeling implementation

traditionalapproaches

use COP lang.

Elicitation and modeling of context-dep. behavior

16

Page 58: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

What COSE supports

requirementselicitation modeling implementation

traditionalapproaches

use COP lang.

Identifying behavioral variations applicable in the same contexts

Elicitation and modeling of context-dep. behavior

16

Page 59: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

What COSE supports

requirementselicitation modeling implementation

traditionalapproaches

use COP lang.

Identifying behavioral variations applicable in the same contexts

Identifying contexts relevant to development in COP

Elicitation and modeling of context-dep. behavior

16

Page 60: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

What COSE supports

requirementselicitation modeling implementation

traditionalapproaches

use COP lang.

Identifying behavioral variations applicable in the same contexts

Identifying contexts relevant to development in COP

Injective mapping to implementation

Elicitation and modeling of context-dep. behavior

16

Page 61: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

COP for adaptive software systems—A rescue robot scenario—

Model case: Sasago tunnel disaster in Japan (in 2012)ceiling boards are collapsedoccurred 1700m far from the entrance

Required services for rescue robots for such disasterRecognizing contexts (location, obstacles..)Supporting autonomous moving

Avoiding collisions with obstaclesSwitching b/w multiple modes

Flying mode ... for avoiding large obstaclesRunning mode ... for saving the energy

Changing b/w normal & abnormal (e.g. no signals from sensors) behavior

H. Watanabe et al., A Study of Context-Oriented Programming for Applying toRobot Development, In COP'15.

17

Page 62: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

COP for adaptive software systems—A rescue robot scenario—

Model case: Sasago tunnel disaster in Japan (in 2012)ceiling boards are collapsedoccurred 1700m far from the entrance

Required services for rescue robots for such disasterRecognizing contexts (location, obstacles..)Supporting autonomous moving

Avoiding collisions with obstaclesSwitching b/w multiple modes

Flying mode ... for avoiding large obstaclesRunning mode ... for saving the energy

Changing b/w normal & abnormal (e.g. no signals from sensors) behavior

H. Watanabe et al., A Study of Context-Oriented Programming for Applying toRobot Development, In COP'15.

{{

layers arepromising

17

Page 63: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Pitfalls in context identification

Can the robot switch from running to flying?

Preemption for handling abnormal situations

sensors &actuatorsfor running sensors &

actuatorsfor flying

running

stably flying

18

H. Watanabe et al., A Study of Context-Oriented Programming for Applying toRobot Development, In COP'15.

Page 64: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Pitfalls in context identification

Can the robot switch from running to flying?

Preemption for handling abnormal situations

sensors &actuatorsfor running sensors &

actuatorsfor flying

running stopping

stably flying

18

H. Watanabe et al., A Study of Context-Oriented Programming for Applying toRobot Development, In COP'15.

Page 65: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Pitfalls in context identification

Can the robot switch from running to flying?

Preemption for handling abnormal situations

sensors &actuatorsfor running sensors &

actuatorsfor flying

running stopping

starting stably flying

18

H. Watanabe et al., A Study of Context-Oriented Programming for Applying toRobot Development, In COP'15.

Page 66: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Pitfalls in context identification

Can the robot switch from running to flying?

Preemption for handling abnormal situations

sensors &actuatorsfor running sensors &

actuatorsfor flying

running stopping

starting stably flying

sliding mode

18

H. Watanabe et al., A Study of Context-Oriented Programming for Applying toRobot Development, In COP'15.

Page 67: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Towards COP for EASSY

Mapping contexts in the real world to contexts in COP

Installing layers at runtime for unknown situation

Prioritize layers to handle preemption

context(e.g. sensor values)

context-dependent behavior

19

Page 68: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Towards COP for EASSY

Mapping contexts in the real world to contexts in COP

Installing layers at runtime for unknown situation

Prioritize layers to handle preemption

context(e.g. sensor values)

map

context-dependent behavior

19

Page 69: Context-Oriented Programming for Adaptive Software Systems · Context-Oriented Programming (COP) [Costanza05, Hirschfeld08] New programming paradigm for modularizing context-dependent

Shonan Meeting (EASSY'15) Sep. 7, 2015

Towards COP for EASSY

Mapping contexts in the real world to contexts in COP

Installing layers at runtime for unknown situation

Prioritize layers to handle preemption

context(e.g. sensor values)

map

This mapping should be adaptable!context-dependent behavior

19