Software Product Lines 15-214 Charlie Garrod, Christian Kstner 1 - - PowerPoint PPT Presentation

software product lines
SMART_READER_LITE
LIVE PREVIEW

Software Product Lines 15-214 Charlie Garrod, Christian Kstner 1 - - PowerPoint PPT Presentation

Software Product Lines 15-214 Charlie Garrod, Christian Kstner 1 Reuse and Variations 15-214 Kaestner toad 3 15-214 Kaestner toad 4 15-214 Kaestner toad 5 15-214 Kaestner toad 6 Reuse and Variation Configuration in Software


slide-1
SLIDE 1

Software Product Lines

15-214 Charlie Garrod, Christian Kästner

1

slide-2
SLIDE 2
slide-3
SLIDE 3

toad

3

15-214 Kaestner

Reuse and Variations

slide-4
SLIDE 4

toad

4

15-214 Kaestner

slide-5
SLIDE 5

toad

5

15-214 Kaestner

slide-6
SLIDE 6

toad

6

15-214 Kaestner

slide-7
SLIDE 7

Reuse and Variation

slide-8
SLIDE 8

Configuration in Software

  • Systems cover all possible functionality

– e.g., Windows, Open Office, Oracle, SAP myERP, Photoshop

  • Specialized software and software for embedded

systems increasingly important

– Mobile divices, sensor networks, automotive systems, consumer electronics, smart cards, ubiquitious computing – 98% of all CPUs in embedded devices [2000] – Resource constraints, heterogeneous hardware

8

slide-9
SLIDE 9

Database Systems

  • Increasing data volumes
  • Resource constraints in

embedded environments

9

slide-10
SLIDE 10

Database Engine

slide-11
SLIDE 11

Printer Firmware

slide-12
SLIDE 12

Linux Kernel

slide-13
SLIDE 13

Linux kernel

 ~6 000 000 Lines of C code  Highly configurable

 > 10.000 configuration options!

(x86, 64bit, …)

 Most source code is “optional”

slide-14
SLIDE 14

15

slide-15
SLIDE 15
slide-16
SLIDE 16
slide-17
SLIDE 17

Software Product Lines in Industry

Boeing Bosch Group Cummins, Inc. Ericsson General Dynamics General Motors Hewlett Packard Lockheed Martin Lucent NASA Nokia Philips Siemens …

slide-18
SLIDE 18

CHALLENGES

19

slide-19
SLIDE 19

a unique configuration for every

person on this planet

33 features

  • ptional, independent
slide-20
SLIDE 20

320 features

more configurations than estimated atoms in the universe

  • ptional, independent
slide-21
SLIDE 21

2000 Features 10000

Features

slide-22
SLIDE 22

199 Configuration parameters

for the optimizer (1600 total)

slide-23
SLIDE 23

Correctness? Correctness?

slide-24
SLIDE 24

Understanding? Understanding?

slide-25
SLIDE 25

Software Product Lines

“A software product line is a set of software-intensive systems that share a common, managed set of features satisfying the specific needs of a particular market segment or mission and that are developed from a common set of core assets in a prescribed way.” SEI

slide-26
SLIDE 26

The Promise

# Products Costs Development without reuse Development with reuse

slide-27
SLIDE 27

CONQUERING VARIABILITY

28

slide-28
SLIDE 28
slide-29
SLIDE 29

Domain Analysis

(feature modeling)

D

  • m

a i n E n g i n e e r i n g A p p l i c a t i

  • n

E n g i n e e r i n g

Domain Implementation

(models, source code)

Requirements Analysis

(feature selection)

Application Derivation

(generator, testing)

Domain knowledge Customer needs Product

slide-30
SLIDE 30
slide-31
SLIDE 31
slide-32
SLIDE 32
slide-33
SLIDE 33

Domain Analysis

(feature modeling)

D

  • m

a i n E n g i n e e r i n g A p p l i c a t i

  • n

E n g i n e e r i n g

Domain Implementation

(models, source code)

Requirements Analysis

(feature selection)

Application Derivation

(generator, testing)

Domain knowledge Customer needs Product

slide-34
SLIDE 34

IMPLEMENTATION

35

slide-35
SLIDE 35

Domain Analysis

(feature modeling)

D

  • m

a i n E n g i n e e r i n g A p p l i c a t i

  • n

E n g i n e e r i n g

Domain Implementation

(models, source code)

Requirements Analysis

(feature selection)

Application Derivation

(generator, testing)

Domain knowledge Customer needs Product

slide-36
SLIDE 36

Runtime Parameters

Parameters, variables, constants

slide-37
SLIDE 37

Parameter

38

slide-38
SLIDE 38

Parameter –i in grep

39

slide-39
SLIDE 39

Global configuration options

class Config { public static boolean isLogging = false; public static boolean isWindows = false; public static boolean isLinux = true; } class Main { public void foo() { if (isLogging) log(“running foo()“); if (isWindows) callWindowsMethod(); else if (isLinux) callLinuxMethod(); else throw RuntimeException(); }

40

slide-40
SLIDE 40

Propagating Parameters

41

durch viele Aufrufe propagiert statt globaler Variable

slide-41
SLIDE 41

Selecting configurations

42

  • Command line

parameters

  • Config file
  • User dialog
  • Source code
slide-42
SLIDE 42

Graph Library

class Edge { Node a, b; Color color = new Color(); Weight weight; Edge(Node _a, Node _b) { a = _a; b = _b; } void print() { if (Conf. COLORED) Color.setDisplayColor(color); a.print(); b.print(); if (!Conf.WEIGHTED) weight.print(); } } class Graph { Vector nv = new Vector(); Vector ev = new Vector(); Edge add(Node n, Node m) { Edge e = new Edge(n, m); nv.add(n); nv.add(m); ev.add(e); if (Conf.WEIGHTED) e.weight = new Weight(); return e; } Edge add(Node n, Node m, Weight w) if (!Conf.WEIGHTED) throw RuntimeException(); Edge e = new Edge(n, m); nv.add(n); nv.add(m); ev.add(e); e.weight = w; return e; } void print() { for(int i = 0; i < ev.size(); i++) { ((Edge)ev.get(i)).print(); } } } class Node { int id = 0; Color color = new Color(); void print() { if (Conf.COLORED) Color.setDisplayColor(color); System.out.print(id); } } class Color { static void setDisplayColor(Color c) { ... } } class Weight { void print() { ... } } class Conf { public static boolean COLORED = true; public static boolean WEIGHTED = false; }

slide-43
SLIDE 43

199 Configuration parameters

for the optimizer (1600 total)

slide-44
SLIDE 44

Limitations

45

  • Variable code scattered in entire program

– Hard to test in isolation

  • Global variables or long parameter lists
  • All code always included

– Binary size, memory consumption – Performance – Unused functionality as attack vector

  • Changes at runtime or load-time?
slide-45
SLIDE 45

Limitations

46

  • Variable code scattered in entire program

– Hard to test in isolation

  • Global variables or long parameter lists
  • All code always included

– Binary size, memory consumption – Performance – Unused functionality as attack vector

  • Changes at runtime or load-time?

compile- time if design pattern

slide-46
SLIDE 46

Preprocessors

conditional compilation #ifdef

slide-47
SLIDE 47
slide-48
SLIDE 48

Berkeley DB

#include "db_int.h" static int __rep_queue_filedone(dbenv, rep, rfp) DB_ENV *dbenv; REP *rep; __rep_fileinfo_args *rfp; { #ifndef HAVE_QUEUE COMPQUIET(rep, NULL); COMPQUIET(rfp, NULL); return (__db_no_queue_am(dbenv)); #else db_pgno_t first, last; u_int32_t flags; int empty, ret, t_ret; #ifdef DIAGNOSTIC DB_MSGBUF mb; #endif // over 100 lines of additional code } #endif

49

slide-49
SLIDE 49

Preprocessor in Java?

  • No native preprocessor
  • Some compilers support conditional

compilation at statement level

  • External tools

class Example { public static final boolean DEBUG = false; void main() { System.out.println(“immer”); if (DEBUG) { System.out.println(“debug info”); printDetails(); } } void printDetails() { ... } }

50

slide-50
SLIDE 50

Munge

  • Simple external preprocessor for Java
  • Originally developed for Swing 1.2

class Example { void main() { System.out.println(“immer”); /*if[DEBUG]*/ System.out.println(“debug info”); /*end[DEBUG]*/ } } java Munge –DDEBUG –DFEATURE2 file1.java file2.java

http://weblogs.java.net/blog/tball/archive/2006/09/munge_swings_se.html

51

slide-51
SLIDE 51

Configurable Graph Library

class Edge { Node a, b; /*if[COLOR]*/ Color color = new Color(); /*end[COLOR]*/ /*if[WEIGHT]*/ Weight weight; /*end[WEIGHT]*/ Edge(Node _a, Node _b) { a = _a; b = _b; } void print() { /*if[COLOR]*/ Color.setDisplayColor(color); /*end[COLOR]*/ a.print(); b.print(); /*if[WEIGHT]*/ weight.print(); /*end[WEIGHT]*/ } } class Graph { Vector nv = new Vector(); Vector ev = new Vector(); Edge add(Node n, Node m) { Edge e = new Edge(n, m); nv.add(n); nv.add(m); ev.add(e); /*if[WEIGHT]*/ e.weight = new Weight(); /*end[WEIGHT]*/ return e; } /*if[WEIGHT]*/ Edge add(Node n, Node m, Weight w) Edge e = new Edge(n, m); nv.add(n); nv.add(m); ev.add(e); e.weight = w; return e; } /*end[WEIGHT]*/ void print() { for(int i = 0; i < ev.size(); i++) { ((Edge)ev.get(i)).print(); } } } class Node { int id = 0; /*if[COLOR]*/ /*if[COLOR]*/ class Color { static void setDisplayColor(Color c) { ... } } /*end[COLOR]*/ /*if[WEIGHT]*/ class Weight { void print() { ... } } /*end[WEIGHT]*/

slide-52
SLIDE 52

2000 Features 10000

Features

slide-53
SLIDE 53

Discussion

  • Compile-time configuration
  • Can remove arbitrary code before compilation
  • Simple programming model
  • Bad reputation

– Scattered code – Error prone – Hard to understand – Invites neglecting design – Hinder tool support

54

slide-54
SLIDE 54

class Stack { void push(Object o #ifdef SYNC , Transaction txn #endif ) { if (o==null #ifdef SYNC || txn==null #endif ) return; #ifdef SYNC Lock l=txn.lock(o); #endif elementData[size++] = o; #ifdef SYNC l.unlock(); #endif fireStackChanged(); } } class Stack { void push(Object o #ifdef SYNC , Transaction txn #endif ) { if (o==null #ifdef SYNC || txn==null #endif ) return; #ifdef SYNC Lock l=txn.lock(o); #endif elementData[size++] = o; #ifdef SYNC l.unlock(); #endif fireStackChanged(); } }

slide-55
SLIDE 55

Femto OS

56

slide-56
SLIDE 56
slide-57
SLIDE 57
slide-58
SLIDE 58

Error Prone

static int _rep_queue_filedone(...) DB_ENV *dbenv; REP *rep; __rep_fileinfo_args *rfp; { #ifndef HAVE_QUEUE COMPQUIET(rep, NULL); COMPQUIET(rfp, NULL); return (__db_no_queue_am(dbenv)); #else db_pgno_t first, last; u_int32_t flags; int empty, ret, t_ret; #ifdef DIAGNOSTIC DB_MSGBUF mb; #endif //over 100 lines of additional code } #endif #ifdef TABLES class Table { void insert(Object data, Txn txn) { storage.set(data, txn.getLock()); } } #endif class Storage { #ifdef WRITE boolean set(…) { ... } #endif }

slide-59
SLIDE 59

Error Prone

static int _rep_queue_filedone(...) DB_ENV *dbenv; REP *rep; __rep_fileinfo_args *rfp; { #ifndef HAVE_QUEUE COMPQUIET(rep, NULL); COMPQUIET(rfp, NULL); return (__db_no_queue_am(dbenv)); #else db_pgno_t first, last; u_int32_t flags; int empty, ret, t_ret; #ifdef DIAGNOSTIC DB_MSGBUF mb; #endif //over 100 lines of additional code } #endif #ifdef TABLES class Table { void insert(Object data, Txn txn) { storage.set(data, txn.getLock()); } } #endif class Storage { #ifdef WRITE boolean set(…) { ... } #endif }

slide-60
SLIDE 60

A matter of scale

 E x a m p l e : S e s s i o n e x p i r a t i o n i n t h e A p a c h e T o m c a t S e r v e r

61

slide-61
SLIDE 61

Design Pattern and Frameworks

best practice separation

slide-62
SLIDE 62

Strategy Pattern

63

slide-63
SLIDE 63

Template Method Pattern

64

slide-64
SLIDE 64

Inheritance for Variability

65

S t a c k S e c u r e S t a c k S y n c h r o n i z e d S t a c k U n d o S t a c k

modular, but inflexible

slide-65
SLIDE 65

Inflexible Extension Mechanism

S t a c k S e c u r e S t a c k S y n c h r o n i z e d S t a c k U n d o S t a c k

S t a c k S e c u r e S t a c k S y n c h r o n i z e d S t a c k U n d o S t a c k

E x t e n s i

  • n

s n

  • t

c

  • m

b i n a b l e Middle extension not optional

  • cf. White-Box Framework
slide-66
SLIDE 66

Work arounds?

  • Combining inheritance

hierarchies

– Combinatorical explosion – Massive code replication

  • Multiple inheritance

– Diamond problem

S t a c k S e c u r e S t a c k S y n c h r o n i z e d U n d o S e c u r e S t a c U n d o S t a c k U n d o S e c u r e S t a c k S y n c h r o n i z e d U n d o S t a c k S y n c h r o n i z e d S t a c k + p u s h ( ) + p o p ( ) + s iz e ( )
  • v a lu e s
S t a c k + p u s h ( ) + p o p ( ) + s iz e ( ) + lo c k ( ) + u n lo c k ( ) L o c k e d S t a c k + p u s h ( ) + p o p ( ) + u n d o( )
  • lo g
U n d o S t a c k L o c k e d U n d o S t a c k
slide-67
SLIDE 67

Decorator Pattern

+ p u s h ( ) + p o p ( ) + s iz e ( ) « in t e r f a c e » I S t a c k + p u s h ( ) + p o p ( ) + s iz e ( )

  • v a lu e s

S t a c k + p u s h ( ) + p o p ( ) + s iz e ( )

  • d e le g a t e

S t a c k D e c o r a t o r + p u s h ( ) + p o p ( ) + s iz e ( ) + lo c k ( ) + u n lo c k ( ) L o c k e d S t a c k + p u s h ( ) + p o p ( ) + u n d o ( )

  • lo g

U n d o S t a c k + p u s h ( ) + p o p ( ) + e n c r y p t( ) + d e c r y p t( )

  • k e y p h r a s e

S e c u r e S t a c k 1 1

slide-68
SLIDE 68

Frameworks

  • Set of abstract and concrete classes
  • Reusable solutions of a set of problems
  • Planned hot spots, extended by plug-ins
  • Extension mechanisms often based on

design patterns –Strategy –Template method –Observer

69

slide-69
SLIDE 69

Discussion

  • Separated, modular extensions

–Compile and test plug-ins separately

  • Compile-time/load-time configuration
  • Well understood in practice
  • Hard to design, hard to evolve
  • Small runtime overhead
  • Suited for coarse-grained extensions

70

slide-70
SLIDE 70

ANALYSIS

71

slide-71
SLIDE 71
slide-72
SLIDE 72

320 features

more configurations than estimated atoms in the universe

  • ptional, independent
slide-73
SLIDE 73

From HP to Linux

2000 Features Inhouse configuration 100 Printers (Product Map) 30 New Printers per Year 10000 Features End user configures 210000 Configurations

∀ p PL . ... ∈

slide-74
SLIDE 74

true

Dead-Code Detection

line 1 #ifdef A line 2 #ifndef A line 3 #endif line 4 #elif defined(X) line 5 #else line 6 #endif

A A ^ not A A not A ^ X not A ^ not X

Dead code

Analysis: SAT(pc(block i))

slide-75
SLIDE 75

Variability Models

76

slide-76
SLIDE 76

4/13/2011

slide-77
SLIDE 77
slide-78
SLIDE 78

Cohen et al. Interaction testing of highly-configurable systems in the presence

  • f constraints. ISSTA 2007

F1 F2 F3

  • n
  • n
  • n
  • n
  • n
  • ff
  • n
  • ff
  • n
  • n
  • ff
  • ff
  • ff
  • n
  • n
  • ff
  • n
  • ff
  • ff
  • ff
  • n
  • ff
  • ff
  • ff

Pairwise Testing

slide-79
SLIDE 79

Cohen et al. Interaction testing of highly-configurable systems in the presence

  • f constraints. ISSTA 2007

F1 F2 F3

  • n
  • n
  • n
  • n
  • n
  • ff
  • n
  • ff
  • n
  • n
  • ff
  • ff
  • ff
  • n
  • n
  • ff
  • n
  • ff
  • ff
  • ff
  • n
  • ff
  • ff
  • ff

Pairwise Testing

slide-80
SLIDE 80

Closed-World Analysis

Specified Variability Implementation Variability

P

WORLD

BYE

WORLD v BYE ¬ (WORLD ˄ BYE) (WORLD v BYE) ˄ ¬ (WORLD ˄ BYE)

Check Consistency

∀ p PL . ∈ p is well-typed

slide-81
SLIDE 81

Other Topics

  • Product planning, product-line scoping
  • Team organization
  • Development and design process

(domain engineering)

  • More implementation techniques

(components, version control systems, feature/aspect-oriented development)

  • Product-line analysis
slide-82
SLIDE 82
slide-83
SLIDE 83

Further Reading

 S. Apel, D. Batory, C. Kästner, and G. Saake. Feature- Oriented Software Product Lines: Concepts and

  • Implementation. Berlin/Heidelberg: Springer-Verlag,

2013.  K. Czarnecki and U. Eisenecker. Generative Programming: Methods, Tools, and Applications. Addison-Wesley, 2000.  P. Clements, L. Northrop. Software Product Lines: Practices and Patterns. Addison-Wesley, 2002

84

slide-84
SLIDE 84

15-313: Foundations of Software Engineering

  • Advanced Topics

– From Design Pattern to Architectures – Dynamic and Static Analysis – Inspection, Advanced Testing – Git, Continuous Integration

  • Human Aspects in Software Engineering

– Teams – Process – Requirements – Economics, Risks – Empirical Results

  • Concurrency and Security as Themes
slide-85
SLIDE 85

Summer Project: Analyzing Github

  • Setup Analysis Infrastructure
  • Metrics for Active Developers
  • Speculative Unit Test Execution
  • Unix, Databases +
slide-86
SLIDE 86

Summary

  • Software product lines: Systematic

reuse by planning variations

  • From runtime parameters and

conditional compilation to design patterns and frameworks

  • Analysis for product lines

87