overview of frameworks: introductionoverview of frameworks douglas c. schmidt 13 • processor &...

83
Overview of Frameworks: Introduction Douglas C. Schmidt [email protected] www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA CS 282 Principles of Operating Systems II Systems Programming for Android

Upload: others

Post on 22-May-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks: Introduction

Douglas C. Schmidt [email protected]

www.dre.vanderbilt.edu/~schmidt

Institute for Software Integrated Systems

Vanderbilt University Nashville, Tennessee, USA

CS 282 Principles of Operating Systems II Systems Programming for Android

Page 2: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

2

• Summarize key framework concepts Domain-

Specific Functionality & Structure

Reusable “Semi-

Complete” Applications

Implement Pattern

Languages

Extensible Design &

Code

Inversion of Control

Framework Concepts

Module Introduction

Page 3: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

3

• Summarize key framework concepts Domain-

Specific Functionality & Structure

Reusable “Semi-

Complete” Applications

Implement Pattern

Languages

Extensible Design &

Code

Inversion of Control

Framework Concepts

Module Introduction

Page 4: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

4

• Summarize key framework concepts Domain-

Specific Functionality & Structure

Reusable “Semi-

Complete” Applications

Implement Pattern

Languages

Extensible Design &

Code

Inversion of Control

Framework Concepts

Module Introduction

Page 5: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

5

• Summarize key framework concepts Domain-

Specific Functionality & Structure

Reusable “Semi-

Complete” Applications

Implement Pattern

Languages

Extensible Design &

Code

Inversion of Control

Framework Concepts

Module Introduction

Page 6: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

6

• Summarize key framework concepts Domain-

Specific Functionality & Structure

Reusable “Semi-

Complete” Applications

Implement Pattern

Languages

Extensible Design &

Code

Inversion of Control

Framework Concepts

Module Introduction

Page 7: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

7

• Summarize key framework concepts Domain-

Specific Functionality & Structure

Reusable “Semi-

Complete” Applications

Implement Pattern

Languages

Extensible Design &

Code

Inversion of Control

Framework Concepts

Module Introduction

Page 8: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

8

• Summarize key framework concepts

• Give examples of frameworks related to Android • developer.android.com

Android frameworks are available in open-source form

Module Introduction

Page 9: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Douglas C. Schmidt [email protected]

www.dre.vanderbilt.edu/~schmidt

Institute for Software Integrated Systems

Vanderbilt University Nashville, Tennessee, USA

CS 282 Principles of Operating Systems II Systems Programming for Android

Overview of Frameworks: Part 1

Page 10: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

10

Learning Objectives of this Module • Understand why hardware has

historically improved more consistently than software

Page 11: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

11

Application-specific functionality

Networking

Database

Electronic Trading

Social Media

Mobile Apps

GUI

Learning Objectives of this Module • Understand why hardware has

historically improved more consistently than software

• Recognize key characteristics of frameworks that help improve software productivity & quality

We’ll give pithy examples of frameworks from Android to reify key concepts

Page 12: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

12

• Processor & network performance has increased by many orders of magnitude in past decades

1,200 bits/sec to 10+ Gigabits/sec

Hardware == Better, Faster, Cheaper

Single-core 10 Megahertz to 3+ Gigahertz multi-cores

Page 13: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

13

• Processor & network performance has increased by many orders of magnitude in past decades

1,200 bits/sec to 10+ Gigabits/sec

Hardware == Better, Faster, Cheaper

• Extrapolating these trends another decade or so yields high-performance commoditized hardware infrastructure • Processors with 100’s1,000’s

of cores • ~100 Gigabits/sec LANs • ~100 Megabits/sec wireless • ~10 Terabits/sec Internet backbone

Single-core 10 Megahertz to 3+ Gigahertz multi-cores

www.dre.vanderbilt.edu/~schmidt/dedicate.html has more on commoditization

Page 14: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

14

Software == Buggier, Slower, & More Expensive?

• Unfortunately, software quality & productivity hasn’t improved as rapidly or predictably as hardware

Page 15: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

15

Software == Buggier, Slower, & More Expensive?

• Unfortunately, software quality & productivity hasn’t improved as rapidly or predictably as hardware

• This is particularly problematic for mission-critical concurrent & networked software-reliant systems

See www.dre.vanderbilt.edu/~schmidt/comm-lessons.html for more info

Page 16: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

16

Why Hardware Improves Consistently Advances in hardware & networks stem largely from maturation

of standardized & reusable interfaces, protocols, & modeling tools

x86 chipsets TCP/IP switches

Page 17: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

17

Historically software developers have manually rediscovered & reinvented “point solutions” that are expensive to develop, integrate, validate, & sustain

Why Software Fails to Improve as Consistently

Proprietary & Stovepiped

Application & Infrastructure

Software

Standard/COTS Hardware & Networks

In general, software has not been as standardized or reusable as hardware

Customized Form Factors

Page 18: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

18

Why Software Fails to Improve as Consistently

Consequence: Small changes in software/hardware have a big (negative) impact on system quality & sustainability

In general, software has not been as standardized or reusable as hardware

Proprietary & Stovepiped

Application & Infrastructure

Software

Customized Form Factors

Standard/COTS Hardware & Networks

Page 19: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

19

A Solution: Software Frameworks

Product Variant 1

Product Variant 4

Product Variant 2

Product Variant 3

Framework- based App & Infrastructure

Software

• Frameworks promote “systematic reuse” by factoring out many general- purpose & domain-specific services from traditional application responsibility

A framework is an integrated set of software components that collaborate to provide a reusable architecture for a family of related applications

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries Virtual Machine Runtime

www.dre.vanderbilt.edu/~schmidt/reuse-lessons.html has info on systematic reuse

Customized Form Factors

Standard/COTS Hardware & Networks

Page 20: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

20

Key Characteristics of Frameworks

www.dre.vanderbilt.edu/~schmidt/CACM-frameworks.html has more info

Software frameworks exhibit several key characteristics that differentiate them

from other forms of systematic reuse

Page 21: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

21

Key Characteristics of Frameworks Application-specific functionality • They exhibit “inversion of

control” via callbacks • AKA, “Hollywood Principle”

See www.dre.vanderbilt.edu/~schmidt/Coursera/articles/hollywood-principle.txt

Page 22: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

22

Key Characteristics of Frameworks • They exhibit “inversion of

control” via callbacks • AKA, “Hollywood Principle”

Page 23: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

23

Key Characteristics of Frameworks Application-specific functionality • They exhibit “inversion of

control” via callbacks • They provide

integrated domain- specific structures & functionality

Page 24: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

24

Key Characteristics of Frameworks Application-specific functionality • They exhibit “inversion of

control” via callbacks • They provide

integrated domain- specific structures & functionality

Database

Electronic Trading

Social Media

Networking GUI

Mobile Apps

Infrastructure domains

Application domains

Page 25: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

25

Key Characteristics of Frameworks • They exhibit “inversion of

control” via callbacks • They provide

integrated domain- specific structures & functionality • e.g., abstract &

concrete classes, control flows, etc.

AsyncTask Params, Progress, Result

Params – Types used in background work Progress – Types used when indicating progress Result – Types of result

execute() onPreExecute() doInBackground() onProgressUpdate() onPostExecute()

Template method

Hook methods

Page 26: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

26

Key Characteristics of Frameworks Application-specific functionality • They exhibit “inversion of

control” via callbacks • They provide

integrated domain- specific structures & functionality • e.g., abstract &

concrete classes, control flows, etc.

• They are “semi- complete” applications

Networking

Database

Electronic Trading

Social Media

Mobile Apps

GUI

Page 27: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

27

Application-specific functionality

Networking

Electronic Trading

Social Media

Mobile Apps

GUI

Key Characteristics of Frameworks • They exhibit “inversion of

control” via callbacks • They provide

integrated domain- specific structures & functionality • e.g., abstract &

concrete classes, control flows, etc.

• They are “semi- complete” applications

Database Hook methods

Page 28: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

28

Key Characteristics of Frameworks • They exhibit “inversion of

control” via callbacks • They provide

integrated domain- specific structures & functionality • e.g., abstract &

concrete classes, control flows, etc.

• They are “semi- complete” applications • Completing a

framework involves instantiating objects & subclassing & overriding “hook methods”

AsyncTask Params, Progress, Result

DownloadAsyncTask onPreExecute() doInBackground() onPostExecute()

execute() onPreExecute() doInBackground() onProgressUpdate() onPostExecute()

Overridden hook methods

Page 29: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

29

Summary • The quality of software (& the

productivity of software developers) has historically lagged hardware (& hardware developers)

Page 30: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

30

Summary • The quality of software (& the

productivity of software developers) has historically lagged hardware (& hardware developers) • Particularly for mission-critical

concurrent & networked software

Page 31: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

31

Summary • The quality of software (& the

productivity of software developers) has historically lagged hardware (& hardware developers) • Particularly for mission-critical

concurrent & networked software • Much cost, effort, & defects stem

from continuous rediscovery & reinvention of core concepts & components across software industry

Page 32: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

32

Summary • The quality of software (& the

productivity of software developers) has historically lagged hardware (& hardware developers) • Particularly for mission-critical

concurrent & networked software • Much cost, effort, & defects stem

from continuous rediscovery & reinvention of core concepts & components across software industry

• Frameworks improve productivity & quality of software development by • Reifying proven software designs &

implementations in selected domains

Page 33: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

33

Summary • The quality of software (& the

productivity of software developers) has historically lagged hardware (& hardware developers) • Particularly for mission-critical

concurrent & networked software • Much cost, effort, & defects stem

from continuous rediscovery & reinvention of core concepts & components across software industry

• Frameworks improve productivity & quality of software development by • Reifying proven software designs &

implementations in selected domains • Amortizing quality assurance efforts

& artifacts

www.dre.vanderbilt.edu/scoreboard

Page 34: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

34

Summary • The quality of software (& the

productivity of software developers) has historically lagged hardware (& hardware developers) • Particularly for mission-critical

concurrent & networked software • Much cost, effort, & defects stem

from continuous rediscovery & reinvention of core concepts & components across software industry

• Frameworks improve productivity & quality of software development by • Reifying proven software designs &

implementations in selected domains • Amortizing quality assurance efforts

& artifacts

We have a long way to go to match hardware engineers use of modeling tools w3.isis.vanderbilt.edu/projects/gme

Page 35: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks: Part 2

Douglas C. Schmidt [email protected]

www.dre.vanderbilt.edu/~schmidt

Professor of Computer Science Institute for Software Integrated Systems

Vanderbilt University

Nashville, Tennessee, USA

Page 36: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

36

Learning Objectives of this Module • Understand how frameworks

compare with other systematic reuse techniques

Page 37: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

37

Learning Objectives of this Module • Understand how frameworks

compare with other systematic reuse techniques

• Recognize the different categories of frameworks

Black-box White-box

Again, we give pithy examples of frameworks from Android to reify key points

Page 38: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

38

Comparing Systematic Reuse Techniques • Class Library Architecture

• Class is a reusable implementation unit in an OO language

• Classes are typically passive

See en.wikipedia.org/wiki/Library_(computing)#Object_and_class_libraries

ADTs

Strings

Locks

IPC

Math

Local Invocations

Files

GUI

App-Specific Functionality

Event Loop

Glue Code

Page 39: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

39

Comparing Systematic Reuse Techniques

See st-www.cs.illinois.edu/users/johnson/frameworks.html

ADTs

Locks

Strings

Files

Invocations

Reactor

Database

NETWORKING

Application- Specific Functionality

Callbacks

GUI

• Class Library Architecture • Class is a reusable implementation

unit in an OO language • Classes are typically passive

• Framework Architecture • Framework is integrated set of classes

that collaborate to form a reusable architecture for a family of apps

• Frameworks own the event loop(s)

Networking

Page 40: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

40

Comparing Systematic Reuse Techniques • Class Library Architecture

• Class is a reusable implementation unit in an OO language

• Classes are typically passive

• Framework Architecture • Framework is integrated set of classes

that collaborate to form a reusable architecture for a family of apps

• Frameworks reify pattern languages

• Component-based & Service-Oriented Architecture • Component is an encapsulation unit with

one or more interfaces that provide clients with access to services

• Components can be deployed & configured via meta-data contained in assemblies

Middleware Bus

Naming

Locking Logging

Events

See www.dre.vanderbilt.edu/~schmidt/report-doc.html for more info

Page 41: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

41

Comparing Systematic Reuse Techniques • Class Library Architecture

• Class is a reusable implementation unit in an OO language

• Classes are typically passive

• Framework Architecture • Framework is integrated set of classes

that collaborate to form a reusable architecture for a family of apps

• Frameworks reify pattern languages

• Component-based & Service-Oriented Architecture • Component is an encapsulation unit with

one or more interfaces that provide clients with access to services

• Components can be deployed & configured via meta-data contained in assemblies

Frameworks are generally more flexible/powerful than other

systematic reuse techniques, but also more complicated to develop & use

Page 42: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

42

Categories of Frameworks • Black-box frameworks only

require understanding external interfaces of objects • Framework elements typically

reused by parameterizing & assembling objects

Page 43: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

43

Categories of Frameworks • Black-box frameworks only

require understanding external interfaces of objects • Framework elements typically

reused by parameterizing & assembling objects

• White-box frameworks require understanding the framework implementation to some degree • Framework elements typically

reused by subclassing & overridding

www.laputan.org/drc/drc.html has more on black-box & white-box frameworks

Page 44: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

44

Categories of Frameworks

• Black-box frameworks reply heavily on object composition patterns, such as Strategy & Decorator

• Each category of OO framework uses different sets of patterns

• Black-box frameworks only require understanding external interfaces of objects • Framework elements typically

reused by parameterizing & assembling objects

• White-box frameworks require understanding the framework implementation to some degree • Framework elements typically

reused by subclassing & overridding

en.wikipedia.org/wiki/Strategy_pattern has more on the Strategy pattern

Page 45: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

45

Categories of Frameworks

• White-box frameworks rely heavily on inheritance-based extensibility patterns, such as Template Method & State

• Black-box frameworks only require understanding external interfaces of objects • Framework elements typically

reused by parameterizing & assembling objects

• White-box frameworks require understanding the framework implementation to some degree • Framework elements typically

reused by subclassing & overridding

• Each category of OO framework uses different sets of patterns

en.wikipedia.org/wiki/Template_method has more on Template Method pattern

Page 46: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

46

• Each category of OO framework uses different sets of patterns • Many frameworks fall in between

white-box & black-box categories

Categories of Frameworks • Black-box frameworks only

require understanding external interfaces of objects • Framework elements typically

reused by parameterizing & assembling objects

• White-box frameworks require understanding the framework implementation to some degree • Framework elements typically

reused by subclassing & overridding

Page 47: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

47

Categories of Frameworks • Black-box frameworks only

require understanding external interfaces of objects • Framework elements typically

reused by parameterizing & assembling objects

• White-box frameworks require understanding the framework implementation to some degree • Framework elements typically

reused by subclassing & overridding

• Each category of OO framework uses different sets of patterns • Many frameworks fall in between

white-box & black-box categories

• In general

• White-box frameworks are easier to develop, but harder to use

Page 48: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

48

Categories of Frameworks • Black-box frameworks only

require understanding external interfaces of objects • Framework elements typically

reused by parameterizing & assembling objects

• White-box frameworks require understanding the framework implementation to some degree • Framework elements typically

reused by subclassing & overridding

• Each category of OO framework uses different sets of patterns • Many frameworks fall in between

white-box & black-box categories

• In general

• White-box frameworks are easier to develop, but harder to use

• Black-box frameworks are harder to develop, but easier to use

Page 49: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

49

White-box Framework: Android AsyncTask • Android’s AsyncTask

provides a simple white-box framework to create long-running operations that need to communicate with the UI thread

developer.android.com/reference/android/os/AsyncTask.html has AsyncTask info

: UI Thread

: My AsyncTask

: Worker Runnable

Perform long-running task

: Default Executor

Initialization actions

Template method

execute

onPreExecute doInBackground

onPostExecute

execute

Display results in UI

Page 50: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

50

AsyncTask execute onPreExecute doInBackground onProgressUpdate onPostExecute

Params, Progress, Result

Params – Types used in background work Progress – Types used when indicating progress Result – Types of result

DownloadAsyncTask onPreExecute doInBackground onPostExecute

• Android’s AsyncTask provides a simple white-box framework to create long-running operations that need to communicate with the UI thread

• Must be subclassed

White-box Framework: Android AsyncTask

Hook methods Template method

Page 51: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

51

class DownloadAsyncTask extends AsyncTask<String, Integer, Bitmap> {

protected void onPreExecute() { dialog.display(); }

protected Bitmap doInBackground(String... url) { return downloadImage(url[0]); }

protected void onPostExecute(Bitmap bitmap) { performPostDownloadOperations(bitmap); dialog.dismiss(); }

}

Download in background thread

Perform on UI thread

Perform on UI thread

• Android’s AsyncTask provides a simple white-box framework to create long-running operations that need to communicate with the UI thread

• Must be subclassed

• Hook methods can be overridden

White-box Framework: Android AsyncTask

Page 52: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

52

• Android’s AsyncTask provides a simple white-box framework to create long-running operations that need to communicate with the UI thread

• Must be subclassed

• Hook methods can be overridden

• Instance must be created on the UI thread & can only be executed once

public class ThreadedDownloadActivity extends Activity { …

public void runAsyncTask(View view) { final String url = urlEditText.getText().toString();

new DownloadAsyncTask().execute(url);

} … }

UI thread calls template method to trigger image download in a new AsyncTask

White-box Framework: Android AsyncTask

Page 53: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

53

• Android’s AsyncTask provides a simple black-box framework for controlling the # & behavior of thread(s) running in background

Black-box Framework: Android AsyncTask

execute

onPreExecute doInBackground

onPostExecute

: Download AsyncTask

: Worker Runnable

: Executor

execute

: Download Activity

developer.android.com/reference/android/os/AsyncTask.html has AsyncTask info

Page 54: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

54

• Android’s AsyncTask provides a simple black-box framework for controlling the # & behavior of thread(s) running in background

• Client can select the desired Executor

Black-box Framework: Android AsyncTask

: Download AsyncTask

: Worker Runnable

: Executor

setDefault Executor (AsyncTask.THREAD_POOL_EXECUTOR)

: Download Activity

Allows multiple long-running tasks to run in

parallel in multiple threads

SERIAL_EXECUTOR, THREAD_POOL_EXECUTOR,

or custom Executor

doInBackground

execute

onPreExecute

onPostExecute

execute

Page 55: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

55

execute

onPreExecute

onPostExecute

execute

• Android’s AsyncTask provides a simple black- box framework for controlling the # & behavior of thread(s) running in background

• Client can select the desired Executor

• Executor treated as a “black-box”

• i.e., only requires understanding of external interfaces

Black-box Framework: Android AsyncTask

www.dre.vanderbilt.edu/~schmidt/PDF/ICCDS.pdf has C++ black-box example

: Download AsyncTask

: Worker Runnable

: Executor

setDefault Executor (AsyncTask.THREAD_POOL_EXECUTOR)

: Download Activity

doInBackground

Executors can be plugged in as a

strategy to AsyncTask

Page 56: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

56

Summary • Frameworks are powerful—but can

be hard to develop & use by app developers due to inherent/accidental complexities of various domains

Page 57: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

57

Summary • Frameworks are powerful—but can

be hard to develop & use by app developers due to inherent/accidental complexities of various domains • Patterns (especially pattern

languages) help to alleviate many framework complexities

www.dre.vanderbilt.edu/~schmidt/PDF/ORB-patterns.pdf has more info

Page 58: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

58

Summary • Frameworks are powerful—but can

be hard to develop & use by app developers due to inherent/accidental complexities of various domains • Patterns (especially pattern

languages) help to alleviate many framework complexities

• It’s often better to use & customize “off-the-shelf” frameworks than to develop frameworks in-house

Page 59: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

59

Summary • Frameworks are powerful—but can

be hard to develop & use by app developers due to inherent/accidental complexities of various domains • Patterns (especially pattern

languages) help to alleviate many framework complexities

• It’s often better to use & customize “off-the-shelf” frameworks than to develop frameworks in-house

• Components & services are easier for app developers to use, but aren’t as powerful or flexible as frameworks

Page 60: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

60

Summary • Frameworks are powerful—but can

be hard to develop & use by app developers due to inherent/accidental complexities of various domains • Patterns (especially pattern

languages) help to alleviate many framework complexities

• It’s often better to use & customize “off-the-shelf” frameworks than to develop frameworks in-house

• Components & services are easier for app developers to use, but aren’t as powerful or flexible as frameworks • Successful software projects are

therefore often best organized using the “funnel” model

Application Developers

Infrastructure Developers

Off-the-Shelf Framework Developers

Infrastructure Developers

www.dre.vanderbilt.edu/~schmidt/PDF/Queue-04.pdf has more on frameworks

Page 61: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Douglas C. Schmidt [email protected]

www.dre.vanderbilt.edu/~schmidt

Institute for Software Integrated Systems

Vanderbilt University Nashville, Tennessee, USA

CS 282 Principles of Operating Systems II Systems Programming for Android

Overview of Frameworks: Part 3

Page 62: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

62

Learning Objectives of this Module • Present Scope, Commonality, &

Variability (SCV) analysis as a method for developing & applying software product-lines & frameworks

Page 63: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

63

Learning Objectives of this Module • Present Scope, Commonality, &

Variability (SCV) analysis as a method for developing & applying software product-lines & frameworks

• Illustrate the application of SCV to Android

Page 64: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

64

Product Variant 1

Product Variant 4

Product Variant 2

Product Variant 3

• A software product line (SPL) is a form of systematic software reuse • An SPL a set of software-intensive

systems • These systems share a common,

managed set of features satisfying the specific needs of a particular market segment or mission

• They are developed from a common set of core assets in a prescribed way

Overview of Software Product-Lines

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries Virtual Machine Runtime

Page 65: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

65

Product Variant 1

Product Variant 4

Product Variant 2

Product Variant 3

• A software product line (SPL) is a form of systematic software reuse • An SPL a set of software-intensive

systems • These systems share a common,

managed set of features satisfying the specific needs of a particular market segment or mission

• They are developed from a common set of core assets in a prescribed way

• Frameworks can help define & improve core SPL assets by factoring out many reusable general-purpose & domain-specific services from application responsibility

Overview of Software Product-Lines

See www.sei.cmu.edu/productlines for more info on software product-lines

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries Virtual Machine Runtime

Page 66: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

66

• Key software product-line & framework structure & behavior can be captured systematically via Scope, Commonality, & Variability (SCV) analysis

Scope, Commonality, & Variability Analysis

Page 67: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

67

• Key software product-line & framework structure & behavior can be captured systematically via Scope, Commonality, & Variability (SCV) analysis

• This process can be applied to identify commonalities & variabilities in a domain

Scope, Commonality, & Variability Analysis

www.cs.iastate.edu/~cs309/references/CoplienHoffmanWeiss_CommonalityVariability.pdf

Page 68: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

68

• Key software product-line & framework structure & behavior can be captured systematically via Scope, Commonality, & Variability (SCV) analysis

• This process can be applied to identify commonalities & variabilities in a domain

• Often used to guide the development & application of software product-lines & frameworks

Scope, Commonality, & Variability Analysis

Product Variant 1

Product Variant 4

Product Variant 2

Product Variant 3

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries Virtual Machine Runtime

Page 69: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

69

• Key software product-line & framework structure & behavior can be captured systematically via Scope, Commonality, & Variability (SCV) analysis

• This process can be applied to identify commonalities & variabilities in a domain

• General method

• Identify common portions of a domain & define stable interfaces (fairly easy)

Scope, Commonality, & Variability Analysis

AsyncTask

execute() onPreExecute() doInBackground() onProgressUpdate() onPostExecute()

Page 70: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

70

• Key software product-line & framework structure & behavior can be captured systematically via Scope, Commonality, & Variability (SCV) analysis

• This process can be applied to identify commonalities & variabilities in a domain

• General method

• Identify common portions of a domain & define stable interfaces (fairly easy)

• Identify variable portions of a domain & define stable interfaces (harder)

Scope, Commonality, & Variability Analysis

AsyncTask

execute() onPreExecute() doInBackground() onProgressUpdate() onPostExecute()

Params, Progress, Result

Params – Types used in background work Progress – Types used when indicating progress Result – Types of result

DownloadAsyncTask onPreExecute() doInBackground() onPostExecute()

Page 71: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

71

• Key software product-line & framework structure & behavior can be captured systematically via Scope, Commonality, & Variability (SCV) analysis

• This process can be applied to identify commonalities & variabilities in a domain

• General method

• Identify common portions of a domain & define stable interfaces (fairly easy)

• Identify variable portions of a domain & define stable interfaces (harder)

• Create different implementations of the variable portions as plug-ins

Scope, Commonality, & Variability Analysis

AsyncTask

execute() onPreExecute() doInBackground() onProgressUpdate() onPostExecute()

Params, Progress, Result

Params – Types used in background work Progress – Types used when indicating progress Result – Types of result

DownloadAsyncTask onPreExecute() doInBackground() onPostExecute()

… onPreExecute() doInBackground() onPostExecute()

Page 72: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

72

• Key software product-line & framework structure & behavior can be captured systematically via Scope, Commonality, & Variability (SCV) analysis

• This process can be applied to identify commonalities & variabilities in a domain

• General method

• Identify common portions of a domain & define stable interfaces (fairly easy)

• Identify variable portions of a domain & define stable interfaces (harder)

• Create different implementations of the variable portions as plug-ins

Scope, Commonality, & Variability Analysis

en.wikipedia.org/wiki/SOLID_(object-oriented_design) has more info

AsyncTask

execute() onPreExecute() doInBackground() onProgressUpdate() onPostExecute()

Params, Progress, Result

Params – Types used in background work Progress – Types used when indicating progress Result – Types of result

DownloadAsyncTask onPreExecute() doInBackground() onPostExecute()

… onPreExecute() doInBackground() onPostExecute()

Page 73: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

73

• Scope defines the domain & context of Android & its various frameworks & components

• e.g., • Resource-constrained

mobile devices • e.g., limited power,

memory, processors, network, & price points

Applying SCV to Android

Page 74: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

74

• Scope defines the domain & context of Android & its various frameworks & components

• e.g., • Resource-constrained

mobile devices • e.g., limited power,

memory, processors, network, & price points

• Touch-based user interfaces

Applying SCV to Android

Page 75: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

75

• Scope defines the domain & context of Android & its various frameworks & components

• e.g., • Resource-constrained

mobile devices • e.g., limited power,

memory, processors, network, & price points

• Touch-based user interfaces

• (Largely) open-source, vendor- & hardware-agnostic ecosystem

Applying SCV to Android

Page 76: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

76

• Scope defines the domain & context of Android & its various frameworks & components

• e.g., • Resource-constrained

mobile devices • e.g., limited power,

memory, processors, network, & price points

• Touch-based user interfaces

• (Largely) open-source, vendor- & hardware-agnostic ecosystem • Focus on installed-base of Java app developers

See developer.android.com for more info on Android

Applying SCV to Android

Page 77: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

77

• Commonalities describe the attributes common across all instances of Android • Common framework

components • e.g., Activities,

Services, Content Providers, & Broadcast Receivers

Applying SCV to Android

Page 78: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

78

• Commonalities describe the attributes common across all instances of Android • Common framework

components • e.g., Activities,

Services, Content Providers, & Broadcast Receivers

• Common application frameworks • e.g., Activity Manager, Package Manager, Telephony Manager, Location

Manager, Notification Manager, etc.

Applying SCV to Android

Page 79: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

79

• Commonalities describe the attributes common across all instances of Android • Common framework

components • e.g., Activities,

Services, Content Providers, & Broadcast Receivers

• Common application frameworks • e.g., Activity Manager, Package Manager, Telephony Manager, Location

Manager, Notification Manager, etc. • Common infrastructure

• e.g., Intent framework, Binder, Webkit, Hardware Abstraction Layer, OS device driver frameworks etc.

Applying SCV to Android

Page 80: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

80

• Variabilities describe the attributes unique to different instantiations of Android

• Product-dependent components • e.g., different “look &

feel” variants of vendor-specific user interfaces, sensor & device properties, etc.

Applying SCV to Android

Page 81: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

81

• Variabilities describe the attributes unique to different instantiations of Android

• Product-dependent components • e.g., different “look &

feel” variants of vendor-specific user interfaces, sensor & device properties, etc.

• Product-dependent component assemblies • e.g., different bundled apps, CDMA vs. GSM & different hardware, OS, &

network/bus configurations, etc.

Applying SCV to Android

SCV can also be applied recursively for all the Android frameworks & layers

Page 82: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

82

Summary • Scope, Commonality, & Variability

(SCV) analysis is an advanced systematic reuse technique

• It helps developers alleviate problems associated with maintaining many versions of the same product that have large amounts of similar software created to satisfy new & diverse requirements

Product Variant 1

Product Variant 4

Product Variant 2

Product Variant 3

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries Virtual Machine Runtime

Page 83: Overview of Frameworks: IntroductionOverview of Frameworks Douglas C. Schmidt 13 • Processor & network performance has increased by many orders of magnitude in past decades 1,200

Overview of Frameworks Douglas C. Schmidt

83

Summary • Scope, Commonality, & Variability

(SCV) analysis is an advanced systematic reuse technique

• It helps developers alleviate problems associated with maintaining many versions of the same product that have large amounts of similar software created to satisfy new & diverse requirements

• The frameworks in Android form software product-lines that enable systematic software reuse across a wide range of apps & infrastructure platforms