De sign Stor ie s E xplor ing and Cr e ating Code fr om a Nar - - PowerPoint PPT Presentation

de sign stor ie s
SMART_READER_LITE
LIVE PREVIEW

De sign Stor ie s E xplor ing and Cr e ating Code fr om a Nar - - PowerPoint PPT Presentation

De sign Stor ie s E xplor ing and Cr e ating Code fr om a Nar r ative Pe r spe c tive Ke vlin He nne y ke vlin@c ur br alan.c om @Ke vlinHe nne y See http://programmer.97things.oreilly.com (also http://tinyurl.com/97tepsk ) and


slide-1
SLIDE 1

De sign Stor ie s

E xplor ing and Cr e ating Code fr

  • m a

Nar r ative Pe r spe c tive

Ke vlin He nne y

ke vlin@c ur br alan.c om @Ke vlinHe nne y

slide-2
SLIDE 2

See http://programmer.97things.oreilly.com (also http://tinyurl.com/97tepsk) and follow @97TEPSK

slide-3
SLIDE 3
slide-4
SLIDE 4
slide-5
SLIDE 5

An Agile Vie w of De sign

L

  • ok for

war d E

stablish a c le ar vision of the whole

Appr

  • ac h de sign in time - dr

ive n, inc r e me ntal slic e s Quantisation as use r

stor ie s, use c ase s,

  • the r

sc e nar io style s, fe atur e s, spike s, pr

  • gr

amming e pisode s, e tc .

L

  • ok for

fe e dbac k Be r

e sponsive and r e ac tive

slide-6
SLIDE 6
slide-7
SLIDE 7

Quantum of F low (QoF )

quaff, v.

To drink deeply; to take a long draught; also, to drink repeatedly in this manner.

quaff, n.

An act of quaffing, or the liquor quaffed; a deep draught.

Oxford English Dictionary

slide-8
SLIDE 8
slide-9
SLIDE 9

Slic ing De sign ove r T ime

Str

uc tur al de c omposition is one vie w

  • f a syste m's de sign

E

.g., a static vie w of c ode str uc tur e

T

e mpor al de c omposition c onc e r ns how c ode is de ve lope d ove r time Build by adding func tionally c omple te

c apabilitie s base d ar

  • und usage goals

F

r

  • m use r

stor ie s to patte r n stor ie s

slide-10
SLIDE 10

Balanc ing Value and Risk

Pr

ior ity me asur e s impor tanc e to a stake holde r , not ur ge nc y Value c an be c onte xt se nsitive

Ke e p in mind that busine ss r

isk is some thing to be manage d It doe s not always manife st itse lf at the

same time or in the same plac e as value or

  • the r

me asur e s of pr ior ity

slide-11
SLIDE 11

Goal- Str uc tur e d Slic ing

De ve lopme nt ste ps in te r

ms of visible , func tionally c omple te slic e s E

.g., use c ase s, use r stor ie s, use r stor y maps, F DD fe atur e s and othe r sc e nar io- base d te c hnique s — e mphasis in e ac h c ase is diffe r e nt, but all ar e r e late d

E

ac h slic e is anc hor e d in a goal and wor ks towar ds an outc ome T

he y c an be applie d r e c ur sive ly

slide-12
SLIDE 12

"Vin on Point", Joseph D Carney

slide-13
SLIDE 13

The new user story backlog is a map Jeff Patton

http://www.agileproductdesign.com/blog/the_new_backlog.html

slide-14
SLIDE 14

Re quir e me nt- Style d T e sting

It se e ms obvious that te sts should

r e late to r e quir e me nts in some way Also c ode - le ve l r

e quir e me nts impose d

  • n one pie c e of c ode by anothe r

But it is anothe r

thing to use a r e quir e me nt- base d style for te sts T

e sts should de fine be haviour , not just pr

  • d and poke at it

Applie s to unit as we ll as syste m te sts

slide-15
SLIDE 15

testIsLeapYear testNonLeapYears testLeapYears yearsNotDivisibleBy4AreNotLeapYears yearsDivisibleBy4ButNotBy100AreLeapYears yearsDivisibleBy100ButNotBy400AreNotLeapYears yearsDivisibleBy400AreLeapYears

Procedural test structured in terms of the function being tested, but not in terms

  • f its functionality:

Tests partitioned in terms of the result of the function being tested: Propositional tests reflecting requirements and partitioned in terms of the problem domain (prefix with test_that if test is required as a prefix):

public static boolean isLeapYear(int year) years_not_divisible_by_4_are_not_leap_years years_divisible_by_4_but_not_by_100_are_leap_years years_divisible_by_100_but_not_by_400_are_not_leap_years years_divisible_by_400_are_leap_years

slide-16
SLIDE 16

Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior. Refactor (verb): to restructure software by applying a series of refactorings without changing the observable behavior of the software.

Martin Fowler, Refactoring

slide-17
SLIDE 17

Functional Operational Developmental

slide-18
SLIDE 18

class access_control { public: bool is_locked(const std::basic_string<char> &key) const { std::list<std::basic_string<char> >::const_iterator found = std::find(locked.begin(), locked.end(), key); return found != locked.end(); } bool lock(const std::basic_string<char> &key) { std::list<std::basic_string<char> >::iterator found = std::find(locked.begin(), locked.end(), key); if(found == locked.end()) { locked.insert(locked.end(), key); return true; } return false; } bool unlock(const std::basic_string<char> &key) { std::list<std::basic_string<char> >::iterator found = std::find(locked.begin(), locked.end(), key); if(found != locked.end()) { locked.erase(found); return true; } return false; } ... private: std::list<std::basic_string<char> > locked; ... };

slide-19
SLIDE 19

class access_control { public: bool is_locked(const std::string &key) const { return std::count(locked.begin(), locked.end(), key) != 0; } bool lock(const std::string &key) { if(is_locked(key)) { return false; } else { locked.push_back(key); return true; } } bool unlock(const std::string &key) { const std::size_t old_size = locked.size(); locked.remove(key); return locked.size() != old_size; } ... private: std::list<std::string> locked; ... };

slide-20
SLIDE 20

class access_control { public: bool is_locked(const std::string &key) const { return locked.count(key) != 0; } bool lock(const std::string &key) { return locked.insert(key).second; } bool unlock(const std::string &key) { return locked.erase(key); } ... private: std::set<std::string> locked; ... };

slide-21
SLIDE 21
slide-22
SLIDE 22

Using Unc e r tainty as a Dr ive r

Confronted with two options, most people think that the most important thing to do is make a choice between them. In design (software or otherwise) it is not. The presence of two options is an indicator that you need to consider uncertainty in the design. Use the uncertainty as a driver to determine where you can defer commitment to details and where you can partition and abstract to reduce the significance of design decisions. Kevlin Henney "Use Uncertainty as a Driver"

slide-23
SLIDE 23
slide-24
SLIDE 24
slide-25
SLIDE 25
slide-26
SLIDE 26

Patterns

Patte r

ns name and r e ason about r e c ur r ing de sign de c isions De c isions may be implic it or

e xplic it, c onsc ious or not

T

he naming of a patte r n c ontr ibute s to de sign voc abular y

Patte r

ns de sc r ibe d in te r ms of c onte xt, pr

  • ble m for

c e s, solution str uc tur e and c onse que nc e s

slide-27
SLIDE 27

Inside the Inte r pr e te r Patte r n

Terminal Expression

evaluate

Expression

evaluate

NonTerminal Expression

evaluate

*

Composite: Composite Composite: Leaf Composite: Component Command: ConcreteCommand Command: ConcreteCommand Command: Command

Client Context

Context Object: ContextObject Composite: Client Command: Client Context Object: Owner Context Object: Client

slide-28
SLIDE 28

Patte r n Usage in Classic JUnit

*

1

TestSuite TestResult

«interface»

TestListener

«interface»

Test run

«role»

TestRunner

*

1

TestCase run setUp tearDown

Command Processor Command Observer Composite Double Dispatch Collecting Parameter Template Method

slide-29
SLIDE 29

Pattern Stories

A patte r

n stor y br ings out se que nc e

  • f patte r

ns in a de sign e xample Captur

e c onc e ptual nar r ative be hind a give n pie c e of de sign, whe the r a syste m in pr

  • duc tion or

an illustr ative e xample

F

  • r

c e s and c onse que nc e s playe d out in or de r , e ac h de c ision illustr ate d c onc r e te ly

slide-30
SLIDE 30

JUnit Storyboard

slide-31
SLIDE 31

History rarely happens in the right order or at the right time, but the job of a historian is to make it appear as if it did.

James Burke

slide-32
SLIDE 32

POSA4 Warehouse Story

slide-33
SLIDE 33

Pattern Sequences

A patte r

n se que nc e c aptur e s the unde r lying nar r ative be hind a stor y A se que nc e c an be de sc r

ibe d and applie d inde pe nde nt of a patte r n stor y

Patte r

n se que nc e s foc us on inc r e me ntal de ve lopme nt

Patte r

n c ompounds ar e e xample s of name d, shor t se que nc e s E

.g., MVC, Pluggable F ac tor y

slide-34
SLIDE 34

T

he Inte r pr e te r patte r n c an be se e n as a patte r n c ompound A r

e c ur r ing se t of ove r lapping and inte r ac ting r

  • le s

It c an also be se e n as a se que nc e

  • f patte r

n applic ation I.e ., 〈Command, Conte xt Obje c t,

Composite 〉

Inte r pr e te r 's Se que nc e

slide-35
SLIDE 35

JUnit Storyboard Distilled

JUnit stor

yboar d c an be summar ise d as a patte r n se que nc e I.e ., 〈Command, T

e mplate Me thod, Colle c ting Par ame te r , Class Adapte r , Pluggable Se le c tor , Composite 〉

A summar

y of the se que nc e doe s not show how r

  • le s inte r

ac t E

.g., what c lasse s play what r

  • le s in

Composite

slide-36
SLIDE 36

Pattern Languages

A patte r

n language c onne c ts many patte r ns toge the r Captur

e s c onne c tions and possibilitie s be twe e n patte r ns, inc luding options, alte r native s and ne c e ssar y ste ps

T

he r e may be many possible se que nc e s thr

  • ugh a language

A lone patte r

n se que nc e c an be c onside r e d a nar r

  • w patte r

n language

slide-37
SLIDE 37

Patte r ns of Value

VAL

UE

O BJE

CT

I

MMUT ABL E

VAL

UE

COPIE

D

VAL

UE

MUT

ABL E

COMPANION CL

ONING

COPY CONST

RUCT OR

CL

ASS

F

ACT ORY

ME

T HOD

CONVE

RSION

ME

T HOD

O VE

RL OAD–

O VE

RRIDE

ME

T HOD PAIR

BRIDGE ME

T HOD

T

YPE- SPE CIF IC

O VE

RL OAD

CE

L L

VAL

UE

VAL

IDAT ING

CONST

RUCT OR

I

MPL ICIT

F

AMIL IAL

CONVE

RSION

O PE

RAT ORS F OL L OW

BUIL

T

  • INS
slide-38
SLIDE 38

POSA5 Re que st Handling

slide-39
SLIDE 39
slide-40
SLIDE 40

James Siddle "Choose Your Own Architecture" – Interactive Pattern Storytelling

Inte r ac tive Patte r n Stor ie s

slide-41
SLIDE 41
slide-42
SLIDE 42

Like snowflakes, the human pattern is never cast

  • twice. We are uncommonly and marvelously

intricate in thought and action, our problems are most complex and, too often, silently borne.

Alice Childress