Top Banner
V1.2 XP and Embedded Software Development – Class #462 Copyright © March 2002-2003 All Rights Reserved [email protected] Object Mentor, Inc www.objectmentor.com Class #462 James Grenning Object Mentor, Inc Extreme Programming and Embedded Software Development 2 XP and Embedded Software Development – Class #462 James W Grenning Copyright © March 2002-2003 All Rights Reserved [email protected] What is the first thing known about a project? Project Management Source: Object Mentor Training
27
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

V1.2

XP and Embedded Software Development – Class #462Copyright © March 2002-2003 All Rights Reserved [email protected]

Object Mentor, Incwww.objectmentor.com

Class #462

James GrenningObject Mentor, Inc

Extreme Programming and

Embedded Software Development

2XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

What is the first thingknown about a project?

Project ManagementSource: Object Mentor Training

Page 2: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

3XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

!

! !

!Source: Object Mentor Training

XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Problems Plaguing the Software Industry

Page 3: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

5XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Simple Waterfall

1 May 1 Nov1 Jul 1 Sep

Analysis

Design

Implementation

Source: Object Mentor Training

6XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Waterfall as Royce Described

1 May 1 Nov1 Jul 1 Sep

Analysis

Design

Implementation

Source: Object Mentor Training

1 May 1 Nov1 Jul 1 Sep

Analysis

Design

Implementation

1 May 1 Nov1 Jul 1 Sep

Analysis

Design

Implementation

Page 4: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

7XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Waterfall as Practiced

1 May 1 Nov1 Jul 1 Sep

Analysis

Design

Implementation

STSTUML

UseUseesUseCases

ERDERD

ERDDD

DDDD

Source: Object Mentor Training

8XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

All the Problems are Saved for the End of the Project

1 May 1 Nov1 Jul 1 Sep

Analysis

Design

Implementation

STSTUML

UseUseesUseCases

ERDERD

ERDDD

DDDD

Source: Object Mentor Training

Test and FixTest and FixTest and Fix

Test and Fix

Test and Fix

Test and Fix

Test and Fix

Page 5: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

9XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Poor Quality

10XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Unrealistic Expectations - Burn OutSource: Object Mentor Training

Page 6: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

11XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Iterative/Evolutionary Development Cycle

Requirements

Design

Code

Test

12XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Typical development cycle – Working Features

Requirements

Code

Wor

king

Fea

ture

s

Design

Page 7: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

13XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Iterative/Evolutionary Development Cycle – Working Features

Requirements

Design

Code

Test

Wor

king

Fea

ture

s

14XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

PlanningGame

Sustainable Pace

Open Workspace

Pair Programming

Simple Design

SmallReleases

Metaphor

ContinuousIntegration Test First

Design

Refactoring

CollectiveOwnership

CodingStandard

CustomerTeam Member

User Stories

AcceptanceTestsXUnit

XP is a set of inter-related values and practices

Values:SimplicityCommunicationFeedbackCourage

Page 8: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

15XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Embedded Software Development

What don’t we have at the beginning of an embedded software project?

16XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

There’s No Hardware

Page 9: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

17XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Embedded Software Development

• No Hardware until late in the project• Target platform != development platform• Computer is hidden from the user• Limited IO• Concurrent execution• Resources are limited• Real time

18XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

The Hardware is not ReadyHow can we start the project?

• Write documents

Maybe there is another way

Funct. SpecV1

Design SpecV2

• Have meetings

• Wait

• Experiment

Page 10: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

19XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

What is XP?

• Values– Communication, Simplicity, Feedback, Courage

• Rights– Do quality work, have a life out of work

• Practices

XP is an Agile methodology for developing software iteratively. XP encompasses a set of values, rights and best practices that support each other in incrementally developing software

20XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Metaphor

CollectiveOwnership Coding

Standard

SustainablePace(40 Hour Week)

ContinuousIntegration

SimpleDesign

PairProgramming

Test-FirstDesign

Refactoring(Design Improvements)

XP Practices

Small Releases

Acceptance Tests

On-siteCustomer

PlanningGame

SHIP

Source: Ron Jeffries, et al., Extreme Programming Installed.

Page 11: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

21XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

USER

STORY

USER

STORY

USER

STORY

Managing Scope

USER

STORY

USER

STORY

USER

STORY

USER

STORY

USER

STORY

USER

STORY

USER

STORY

USER

STORY

USER

STORYUSER

STORY

USER

STORY

USER

STORYUSER

STORY

USER

STORY

USER

STORYUSER

STORY

USER

STORY

USER

STORYUSER

STORY

USER

STORY

USER

STORYUSER

STORY

USER

STORY

USER

STORYUSER

STORY

USER

STORY

USER

STORYUSER

STORY

USER

STORY

USER

STORY

GetHigher Business Value

Lower Business Value

Source: Object Mentor Training

Don’t get (yet)

22XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Stories

• Off-hook generates dial tone• On-hook• Extension calls extension• Extension calls busy extension• Flash, call transfer• Flash, three way call• Extension goes off-hook dials “9” and a line is

available

Page 12: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

23XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

There’s No Hardware

24XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Separate Core System Logic from Hardware Specifics

Network

Page 13: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

25XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Test Core System Logic Independent of Hardware Specifics

Tests andSimulations

Tests andSimulations

26XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Acceptance Tests

• Slice off the hardware dependent outer layer• Develop an application specific test language• Run the full automated acceptance test suite

multiple times per day, on your development platform

LINECARD 1 OFFHOOKVERIFY LINECARD 1 DIALTONELINECARD 1 ONHOOKVERIFY LINECARD 1 NODIALTONE

Page 14: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

27XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Initial Architectural Vision(in UML)

<<interface>>LineCard

+ dialToneOn()+ dialToneOff()

CallProcessor

+ onHook(LineCard)+ offOff(LineCard)

FakeLineCard

SS5Model3LineCard

28XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Unit Test the Initial Architecture

//CallProcessorTest.cpp #include "TestHarness.h" #include "CallProcessor.h" #include "FakeLineCard.h" TEST(CallProcessorTest, DialTone) { CallProcessor* cp = new CallProcessor(); FakeLineCard* lc = new FakeLineCard(); CHECK(lc->isDialToneOn() == false); cp->offHook(lc); CHECK(lc->isDialToneOn()); delete cp; delete lc; }

Page 15: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

29XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Separation of Concerns

Separate the interface from the implementation

Keep the interface simple and easy to use

//LineCard.h class LineCard { public: virtual void dialToneOn() = 0; virtual void dialToneOff() = 0; }

30XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Separation of Concerns

//FakeLineCard.h #include "LineCard.h" class FakeLineCard : public LineCard { public: FakeLineCard() : dialToneOn(false) { } void dialToneOn() { dialToneOn = true; } void dialToneOff() { dialToneOn = false; } boolean isDialToneOn() { return dialToneOn; } private: bool dialToneOn; }

Hide implementation details behind the interface

Here is a hidden implementation for

running tests

Page 16: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

31XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Separation of Concerns

//SS5Model3LineCard.h class SS5Model3LineCard : public LineCard { public: SS5Model3LineCard () { } void dialToneOn() { //twiddle the bits to turn on dialtone } void dialToneOff() { //twiddle the bits to turn off dialtone } private: //Whatever member variables //are needed //etc. }

Hide implementation details behind the interface

Here is a hidden implementation for

For a specific line card

32XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Initial Architecture Implementation

//CallProcessor.h #include "LineCard.h" class CallProcessor { public: void onHook(LineCard* lc) { lc->dialToneOn(); } void offHook(LineCard* lc) { lc->dialToneOff(); } }

Unknown to CallProcessor,

the test implementation

is used

Page 17: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

33XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Run The Test

Red Bar means

some test failed

34XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Fix the bug

Run The Test Pavlov’s

Programmer

Green Bar means all tests pass

Page 18: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

35XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Evolutionary Design

• All Designs Evolve• Refactoring (incremental design improvement)• Automated testing supports design evolution

– Test Driven Design– Automated Unit Tests– Automated Acceptance Tests– Tests are the safety net

Unit Tests Acceptance Tests

36XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Evolutionary Design<<interface>>

LineCard

+ DialToneOn()+ DialToneOff()

LineCardSimulation

CallProcessorImplementation

SS5Model3LineCard

Now the SS5Model3LineCard can’t be tested w/o the CallProcessor

Page 19: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

37XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Evolutionary Design

<<interface>> LineCard

+ DialToneOn() + DialToneOff()

<<interface>> CallProcessor

+ OnHook(LineCard) + OffOff(LineCard)

LineCard Simulation

CallProcessor Implementation

SS5Model3 LineCard

CallProcessor ForTestingLine

Cards

38XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Evolutionary Design Concurrency - More separation of concerns

•Separate concurrency model from the behavior logic.•ActiveLineCard applies the threading policy to the line card’s operations

<<interface>>LineCard

+ dialToneOn()+ dialToneOff()

ActiveLineCard

SimulatedLineCard

SS5Model3 LineCard

Page 20: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

39XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Limited Resources

• Simulation helps to get the logic right• But, that may make you careless with resources• Run in the target to understand all dependencies• Measure critical resource usage• Use data, not hunches to decide when to optimize• Use data, not hunches to know when trouble is

coming

40XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Limited Resources

• Design tests that monitor critical resource usage– Test for memory leaks– Stack high water mark

• Use Big Visible Charts (BVC)– Memory usage– IO Bandwidth usage– Idle time– Hand draw or automatically generate– Look for troubling trends

Page 21: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

41XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Memory Leak Test

... long heapSize = freeSpace(); //Run all unit tests assertEquals(heapSize == freeSpace());

... long int heapSize = freeSpace(); //The system runs all aceptance tests //The system exists reportError(heapSize != freeSpace());

//The systems runs all acceptance tests//The system exists

42XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Memory Usage BVC

Flash Usage

0

200

400

600

800

1000

1200

1 2 3 4 5 6 7 8 9 10 11 12

Iteration

Flas

h Us

ed (K

Byt

es)

Flash MaxCodeTablesTotal Used

Page 22: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

43XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Memory Usage BVC

RAM Usage

0

50

100

150

200

250

300

1 2 3 4 5 6 7 8 9 10 11 12

Iteration

RA

M U

sed

(K B

ytes

)

RAM MaxDataHeapStackTotal Used

44XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Idle Time BVC

CPU Idle Time

0

20

40

60

80

100

1 2 3 4 5 6 7 8 9 10 11

Iteration

% Id

le T

ime

Load Test

Page 23: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

45XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Real Time

• Performance Stories– 50,000 Lines– 10% of lines go off-hook simultaneously, dial-tone

within 2 seconds

• Acceptance tests• Unit tests with time check• Hammer and Monitor• Solve performance problems using data

46XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Hammer and Monitor

Hammer in a traffic

loadMeasure

AcceptanceTest

Test results127 tests pass4 tests failed

Page 24: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

47XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

But I don’t have the right tools

• Inability to run code on the build system– Tests must be run on the target

• There is no unit test tool like JUnit or CppUnit for your development or execution environment– Write a simple one

• Compiler incompatibility– Tests can be used to find compiler differences

• No OO programming language (Java, C++)

48XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

No OO Programming Language

• OO promotes decoupling • Decoupling enables testing

• C++ is C• OO constructs in C++ can be taken advantage of for little

or no additional cost• If you are careful

• Decoupling can be done in C, but is harder and requires more discipline

Page 25: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

49XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

But I have a Safety Critical System

• Safety critical is about – Understanding the safety requirements– Documenting the process– Thoroughly testing the product

• Understanding the requirements– Every project regardless of process needs this for success.– Build teams around good people

• Thoroughly test the product– Aligns with XP testing goals– This is a function of good people, knowing the safety requirements

50XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

What about Documentation?

• Documentation is not evil. It is expensive and can get out of date.

• Challenge yourself: Understand why the documents are needed

• Are there other alternatives?– Can the documents be automatically generated

– Can the traceability document be generated from the acceptance test running and recording the path trough the code?

– Write the documents when they are the best way to meet the need

– Can you write the documents as-built rather than as-anticipated?

Page 26: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

51XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Safety Critical

• XP is a incremental design and delivery strategy– This technique is orthogonal to the application domain

• Do you need to add more?– Safety requirements analysis– Additional reviews– Completeness testing– Safety critical systems design best practices

• More work needs to be done

52XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Conclusions

• XP can help– Early progress prior to hardware– Testing safety net– Lower cost of change– Use BVCs for critical resources

– Tools may be a problem– May have to explore new ground

– Real time– Safety critical

• XP is an Agile development technique – look to the values for guidance

Page 27: Embedded Extreme Programming - Embedded Systems Conference 2002-2004

53XP and Embedded Software Development – Class #462 James W GrenningCopyright © March 2002-2003 All Rights Reserved [email protected]

Agile Manefesto (www.agilemanifesto.org)

We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value:

Individuals and interactions over processes and tools

Working software over comprehensive documentationCustomer collaboration over contract negotiation

Responding to change over following a plan

That is, while there is value in the items on the right, we value the items on the left more.