You are on page 1of 334

1

* **
* ( ** )
2

(BUG

; demo ) (

: www.AgileMethod.csie.ncu.edu.tw k

!
4

vs.
( ( ) )

:
5

p. 7 p.198 ( ) (eXtreme Programming, XP) , myAgile myAgile C# Java


6

p.288 p.323

(information) (object) (relationship) (abstraction) ( : 0,1) 0,1) (computer software) (information) : (software) NO!
8

( ** (

*) *)

(
(Test(Test-driven development,TDD)
* ** ( ( cognitive informatics) modal logic)

Bossavit *

Bossavit,The Unbearable Lightness of Programming ,available at: www.cutter.com


10

(Cont.)
Bossavit (passion) (daring) (glamour) , :

(courage)

11

--

? ! ( , , )

? e
12

(Cont.)
: A :IKEA , B : C : C ( A ) , , , , , ,
13

*
( , , , , : ) ,

, 2009.11.29.

14

( ,

) ,

, , ,

15

Agile
(agile) :

1)
:

2)
:
16

1)
:

(being able to support change)

17

Communication Channels
A. Cockburn, Agile Software Development, p.95,Addison-Wesley, 2002. p.95,Addison-

18

Communication Channels (Cont.)


: 1. 2. 3. E-mail ( m : 1. ( )2. 3.
19

(
(
    

)
)

(video link) e-mail : (paper or document)

Document communication ( ) Face to face communication (

20

Face to Face Communication

Document Communication
21

Document Communication
( , , command file : 1) 2)
22

)-

Document Communication (Cont.)


: , ( , ( ! x ( ( )
23

. ? ) ) . . , ,

?
face to face communication document communication ( CMMI*)

demo bugs
* Capability maturity model integrated (CMMI) Mellon University (CMU) Carnegie

24

(communication channel)

(communication purpose)

25

A. Cockburn,
  

: ) ) )

1) inform ( 2) remind ( 3) inspire (

26

1) inspire ( ) remind ( : inform : inform


27

(Cont.)


2) Cockburn , ( ,
28

pair programming) , ,

(Cont.)


3) ( , , (inform & inspire ) ) ) Email , (remind !( ) )


29

( , ,

, : remind : inform , hyperlink

, ,

,video ,

, video
30

CMMI and
CMMI Level 2 (project management) CMMI Levels 3,4,5 (engineering and process management) * m
* Sison and Yang, Use of Agile Methods and Practices in the Philippines, Asian Pacific Software Eng. Conf. (APSEC), Nagoya, Japan, 2007.
31

CMMI and
CMMI level 5 *:

(Cont.)

check list goals,

: validate .
32

* Jacobsen et. al., Mature Agile with a Twist of CMMI, Agile 2008.

XP 2010 Report*) ,

(Best Experience Norway : (work item) (work flow) ; timetimeboxed iteration ( ) . CMMI : CMMI , : myAgile ,

CMMI and

(Cont.)

* J.O.Birkeland, Moving to Flow-based Software Development, FlowXP 2010, Norway.


33

CMMI

 

( (


~ changed human life) ) pair programming

34

(Cont.)


CMMI Programming, XP)

(Extreme

) XP

( CMMI

35

(Cont.)


36

Agile Method vs. Agile Process


Method ObjectObject-oriented (O-O) Method (OProcess method Agile Process* Agile Method *
XP 200X conference Agile Processes in Software Engineering and eXtreme Programming.
37

: 1. ( 2. 3. 4. 5. ( ( ( ( ( ) ) ) ) )
38

(Osmotic Communication)
(ear contact) (eye contact)

)
39

common white board

caves

40

(Cont.)
common Common : cave ( Cave : : pair programming)

e-mail, , white board


( 99 )
41

30

( ) ( ) : BUG

BUG ( : ?

! )

42

1. 2. 3. (

test code

( test test code )

4. 5. ( 6. 7. 8.

hypertext (

hyperlink) )

!!
43

!
[ 2006]

: cost down

, , cost up, value up,

44

(Cont.)
Slow, but Firm (slow) , , ! , Bugs, , (firm) ,

45

Cost Down
Cost Down , : , , ,
* Paul Hawken, : ,

, , ,

cost down, , ,
, 2005.
46

*
, , 4.5 , ; ( , )
47

; (1.36 )

* Martin Fowler web site, posted June 14, 2010.

(Cont.)
, 1) 2) 3) , 4) ( 5) U-Pod , , ! ! , , , build ) Central Desk eye contact ear contact
48

: ,

(Cont.)
information radiator ( ) , ! kanban ( ), (just in time) , ,
49

(Cont.)

50

kanban ( ) XP 2010 in Norway Toyata , ,

51

A call for craftsmanship *




developers

bugs


Its time to SLOW down!

* Ketil Jensen, Improving software quality with Kanban, XP 2010. * http://ketiljensen.wordpress.com/2010/08/19/improving-the-quality-ofsoftware-with-kanban-and-xp-practices/

52

Slow down to go FAST limit work in progress




100%
53

Why introduced kanban?*

Kanban

transparency

cooperation

--- which are key values in agile method.

individual results, team results! 15%

* Olav Maassen & Jasper Sonnevelt, Kanban at an Insurance Company Are You Sure?, XP 2010.
54

Experiences and recommendations about introducing kanban

leader team is doing, Kanban

what, why, how the

waterfall

scrum transparency

It s all about COMMUNICATIONS!


--55

From Chaos to Kanban, via Scrum*


Agile
debug

Kanban
unit

agile method

kanban

From Chaos to Kanban, via Scrum


Not Started In Development Done

Not Started

In Development

Done

Internal acceptance

Customer Live acceptance

Not Started

In Development

Done

Customer acceptance

Google Culture Ideal for Agile & Kanban? *


Google Culture: Run Agile for 2 years recently take some kanbans Google (depend on skill) Engineers (team-based) 20% (passion) Kanban ( )

* Susan Hunter ,Google Culture Ideal For Agile & Kanban,XP2010 video.

Google Culture Ideal for Agile & Kanban?


Agile lean practices

Kanban ( queue

* ** (evolve) m

, , 1972, The Discipline of Design, by Roe,Soulis,and Handa. ** , , 2008, Cradle to Cradle, by McDonough and Braungart. *** 2009 , ,2010 , !
60

(Cont.)
( , , ,
* , ( ), ,2010,pp.163-164. ,2010,pp.163-164.
61

, .

    

Creativity Usability Dependability Maintainability Efficiency ;

62

, * : 1) 2) , (concentration) (determination), ,
* , , , 2006.
63

, , . , . , , *
* , ,

, , ,

, 2010.12.24.
64

?
( : : , , : 90 30 65

?(Cont.)
, ( . , ! , , . ( , , )
66

, ) 2) : ( ),

:1)

?(Cont.)
: , , ? , : , ,
67

?(Cont.)
Microsoft 1) 2) 3) ,
* , 2010.11.8, p. 30.
68

*: ,

(
A. Cockburn 1. 2. 3. 4. 5. :

Getting to meeting on time Answering questions from other people Bothering to mention things they notice Following group coding conventions Using code libraries

[ 2009.9.20]

,
69

Cockburn

70

1.

: ? *

2.

: ( embedded systems)?

*
71

? : ( * ** * ** m ) ( ( ) )

e Java,C#,C DB/Ruby/PHP SemanticWeb Description Logic

72

(Cont.)
2008 t , , ; , : ,

, ( , , , ? )
73

(Cont.)
: ! : :

74

(Cont.)
: coding , API (application program interface) , ! : : scenarios, acceptance test cases; CRC ; unit test cases ; , , . , !
75

(Cont.)
(O(O-O) discussion ? , : ; , m * panel (reuse) , o O-O

76

(Cont.)
, O-O, , classes (reusable) classes scenarios scenarios ,

77

(Cont.)


, , device,


, ,

(cloud computing) , , user interface , (personal computer, PC) server ,

78

(Cont.)
(data structure) . , class interface , class ,class method , Big O method Worst time, Average time, : array, , !
79

(Cont.)


, , : ,

(Compiler)

. , : scanner, parser, intermediate code generator, assembly code generator. scanner, parser , ! ,Operating System, Data Base System Compiler , , !
80

(Cont.)
( ) , ( ,
81

, )

(Cont.)
MIT CSAI Lab ! ), security, compiler 2010
* ** , 2010.7. , 2010.11.1.

Victor (

* )

: : ( operating system,

, **

82

(Cont.)
( ; 2.8% * , Store , (htc) . , 2011
* ** *** , 2010.9.20. , 2011.4.11. , 2011.2.22.

), 15%, App

, ; ; ** ,

iPad App Store, , ; Android *** ,

, iPhone

83

( : *

)?

? *
C C , ( ) ,
84

(Cont.)
: O-O O! : O-O O; ; Java (O-O) (O85

O-O

C++

(Cont.)
: O-O : (extend) ( X Y), polymorphic reference (x X subclass Y object) dynamic binding (whatIAm() bind method), . ,
86

An Example of Extension
/* */public class X { int a; */public public String whatIAm() {return Im an X.;} } //end of class X /* */public */public class Y extends X { int b; public String whatIAm() { return Im a Y.;} } //end of class Y

87

public static void main (String[ ] args) throws IOException { X x; // reference x is declared to be of class X BufferedReader reader = new BufferedReader (new InputStreamReader (System.in); if (reader.readLine().equals ( X)) x = new X(); // x points to an object of class X else (reader.readLine().equals ( Y)) x = new Y(); // x points to an object of class Y System.out.println (x.whatIAm());//dynamic binding } // end of main

88

(Cont.)
, class class relationships (aggregation, use, and inheritance) ,

,
89

(Cont.)
: , : ), , , , !
90

, , (

(Cont.)
: , : Notebook , (PC ) , , ! Java , :
91

, 1) 2) 3) , ,

, run ,m , , (

, )

, ,

: ? ?
92

(Cont.)
2009 396 , *** 2010 800 , , (
* ** *** , 2009.11.6. , 2009.11.30. , 2010.9.5 ****

, ; **

* , 12 , ****

, ), ,

2010.9.30.

93

, , , , , , , , , ; , , , , ! . , ,

94

(Cont.)
, , ( , , Bella Vita, , , , , !
95

! )

, , , , , !

(Cont.)
, , ( , * 2011
* , 2010.8.10.

, , ) !

96

(Cont.)

7500 : , ,

, ! (Jason Wu) !
97

(Cont.)
* ( , , ) , . **, ! GDP , , :

***

* John & Doris Naisbitt, The 8 Pillars of a New Society: Chinas Chinas Megatrends, , , 2009.10.26. ** *** , , , , 2009.5.1, pp.186-191. pp.186, , 2011.2.1, pp. 112-113. 11298

(Cont.)
2010 , ,120 , , 600 ! ), , (

99

(Cont.)
2010 : , , , , , , , , ,

100

(Cont.)
2010 , , , , , , .

,
101

(Cont.)
Economic Cooperation Framework Agreement (ECFA) ; , , , !
102

( ) , ? , ?

(Cont.)


: ; ,

4.6 , )

, m , ,

,
103

(Cont.)


104

(Cont.)
Regent

* , 2010.4.17.

105

(Cont.)
, , (Regent), * : ,
* ** , 2010.8, pp. 356-357. 356, 2010.9.20.
106

, , **

(Cont.)
, , 85
*

, ,

C
, 2010.9, pp. 266-267. 266-

107

(Cont.)
, , (Herb Garden), , , ,
108

, ,

, 750 ,

(Cont.)


(Chris)]
109

(Cont.)


(Chris)]
110

(Cont.)


, : IT (information technology) ET (energy technology), * **, ,


* ** , 2010.1.17. , 2010.10.10.
111

(Cont.)
: , ; * : , t , ,

, 2010.12.18.

112

(Cont.)
2010 , : , , , , , , , , ,
113

Evian, , , , , . , , , ,

IBM,

.
114

(Cont.)
, ) CMMI), , , process ! ( ( , !

115

* , , ,

: ,

O-O ,
* , 2010.6.28.

116

2007 ( ) .. :

117

2009 luxury and genius) , ( , ,

LUXGEN (for

) ,

118

(Cont.)

[web site

, Sep. 2009] ,
119

(Cont.)
(Runes of Magic) , . (35 ) (31) , , ,2005 . , , ! 13 , , 4000 , 800
, 2010.8, pp. 366-367. 366120

(Cont.)
, android , , 1100 , , ,
* , 2010.7.19, p.44.

121

122

*
) ( ( Unified Modeling Language, UML : )

* Martin Fowler, From Nothing, to Monumental, to Agile , http://www.martinfowler.com


123

?


: ! (planning, but no plan) (CRC) (sequence diagram, class diagram ) (tasks) ( ) l


124

*( 200 ?

**) 1000 ***

* * ***

50

125

: 1)system analyst (SA), 2)system designer (SD), 3)programmer (PR) project manager (PM) designerdesigner-programmer developer (1 2 programmers 2 developers in pair-programming; 3 4 pair2 pairs) ( ) SA PM developer test cases test code
126

(Cont.)


: Coach ( ) Coach :


127

(Cont.)
Diversity and Software Development Scott E. Page** : m *

Diversity perspective, interpretation, heuristics, and predictive model . 1949 , *** ( , )

*IEEE Software, May/June 2009. ** XP 2010, Norway, keynote speaker. *** , , ,2009.8.31. ,2009.8.31.

128

: :

  

!)

129

(On(On-site usage expert)


( onon-site customer : ? ?

( part time( full time) Email,

) ( )
130

: 1. 2. 3. 4. (Scenarios) ( methods ( 3 5 243


131

data) ) )

(Cont.)


( ( : : ,

) Microsoft WORD)

 

132

(Cont.)


,
133

(Cont.)
:

134

(extreme)

1) 1) 3)

2) 2) JUnit
135

, , , : (Shu Ha Ri) , ; Agile 2010 ,


136

Cockburn

Made to Stick, Heath, 2007. at www.madetostick.com


137

1990 Stanford Univ. 25 ) 50% (

) 2.5%

(Cont.)
k *: (The Curse of Knowledge)

myAgile

,
* Made to Stick: Why Some Ideas Survive and Others Die), 139 ( ), , 2007, pp. 29-30. 29-

(Cont.)
: ! : ? :
140

(Cont.)
: (knowledge) user : user : 2F , , (sign) , knowledge?
141

, ,

users user (sign) , food court,

(Cont.)
: debugger debugger

142

(story) (scenario)

CRC(

) (use case) O-O


143

(Cont.)


O-O

144

     

simple unexpected concrete credible emotional stories

145

1961 v

: !
146

(Cont.)
Nordstrom
 

1) 2) ) ?

Macy (

Ans: 2)
147

XP 2010 Best Research Paper* , , Fagei action research agile method. : redundant knowledge, . action Scrum meeting team estimate of tasks action ,
* T.E. Fagei, Adoption of Team Estimation in a Specialist Organizational Environment, XP 2010, Norway.
148

Extreme Programming (XP) Agile Method

149

XP Core Practice
1. Fine scale feedback . TestDrivenDevelopment via ProgrammerTests and ProgrammerTests CustomerTests CustomerTests (were UnitTests & AcceptanceTests) UnitTests AcceptanceTests) PlanningGame WholeTeam (was OnsiteCustomer) OnsiteCustomer) PairProgramming 2. Continuous process rather than batch ContinuousIntegration DesignImprovement (was RefactorMercilessly) RefactorMercilessly) SmallReleases

150

XP Core Practices (Cont.)


3. Shared understanding SimpleDesign (DoSimpleThings, YouArentGonnaNeedIt, DoSimpleThings, YouArentGonnaNeedIt, OnceAndOnlyOnce, SimplifyVigorously) OnceAndOnlyOnce, SimplifyVigorously) SystemMetaphor CollectiveCodeOwnership CodingStandard or CodingConventions 4. Programmer welfare FortyHourWeek) SustainablePace (original name: FortyHourWeek) * http://c2.com/cgi/wiki?ExtremeProgrammingCorePractices

151

XP values


[wikipedia]

Extreme Programming initially recognized four values in 1999. A new value was added in the second edition of Extreme Programming Explained. Explained. The five values are: Communication Simplicity Feedback Courage Respect

    

(see next page)


152

Respect


The respect value manifests in several ways. Team members respect each other because programmers should never commit changes that break compilation, that make existing unit-tests fail, or that otherwise delay the work of unittheir peers. Members respect their work by always striving for high quality and seeking for the best design for the solution at hand through refactoring. Adopting four earlier values led to respect gained from others in team. Nobody on the team should feel unappreciated or ignored. This ensures high level of motivation and encourages loyalty toward the team, and the goal of the project. This value is very dependent upon the other values, and is very much oriented toward people in a team.
153

Agile
In 2001 in Utah, agile was coined by agile the Agile Alliance to stress importance of: being able to respond to changing requirements within the project time frame. Lightweight was not adopted because it Lightweight was regarded as too much of a reaction against something (heavyweight), and not enough of a belief in something.

154

Agile revisited
2001 Utah , (Agile Manifesto), ,Agile 2011 conference Utah, keynote speaker ,

155

Agile Method
values Individual and interactions over processes and tools. 2) values Working software over comprehensive documentation. 3) values Customer collaboration collaboration over contract negotiation. 4) values Responding to change over following a plan.
156

1)

myAgile

157

1.Pair Programming
v j

 (drive) (review) 

(Better work in less time) (pride-in-work) pride-in158

1.Pair Programming (Cont.)


1) ( ) l e e ( ) 3) (act spontaneously)

2) 4)

:[

]
159

1.Pair Programming (Cont.)


ego : ( ( : , rotation), pairing ! ) (iteration) ! !
160

1.Pair Programming (Cont.)


pair programming? : , , , pair programming ,

161

1. Pair programming (Cont.)


     

1. 2. 3. 4. 5. 6. (

pair programs.( (

) )

distributed pair programming )


162

Pair Programming


Pair programming t programmer pair programming k

(Silver)]
163

pair programming studies

after adjusting, pairs produced code 15% more slowly than individuals...
reference: http://qconsf.com/sf2008/file?path=/qcon-sanfran2008/slides//NealFord_10_Ways_to_Improve_Your_Code.pdf

pair programming studies

...with 15% fewer defects


reference: http://qconsf.com/sf2008/file?path=/qcon-sanfran2008/slides//NealFord_10_Ways_to_Improve_Your_Code.pdf

Reviewer vs. Supporter


Reviewer , driver , driver . supporter. Reviewer , : API , , API . Supporter : 1) Programming skill domain knowledge driver 2) driver , ( driver , )
[ (Lala)]
166

Rotation in Pair Programming




Rotation (

Pair Programming iteration iteration

)
167

Collective Code Ownership




,


Pair Programming rotation , ! , (reuse) , , , , , ,

168

2. Re-factoring Re(reuse) 1. ( 2. 3. ( (test code,JUnit ) ) ) :

:interface ( interface
169

Reuse

vs. Refactor
, Reuse( , )

( open source) : )

Refactor( ,  ,

,  df

170

3. Continuous Integration .
public method code ( ) ( method methods : method
171

unit test )

integration phase

3. Continuous Integration (Cont.)




Method

 

: method method method method method method test stub)


172

3. Continuous Integration (Cont.)


: unit (method) (bottom(bottom(continuous

up) integration), unit testing ( ) (integration testing)

173

4. Simple Design
* CRC 1) class 2) classes ( (
* [IKEA >

) : (interface) : ) )
] > >

class

174

5. Release (
( ( ) (user stories) ( )

(releases) release releases (evolve)

175

6. Iteration (
( ) j * (
* release ** (

)
( ) **

)
:Ruby/PHP Java ) 5 2-3

176

6.
method

(Cont.)
: class

(user story)

177

7. * (daily stand-up meeting) stand-

(
* , : , ,

178

Communication Cycle

Pair Programming with On-site Customer 1..N Bugs CYCLE TIME 5 seconds CYCLE TIME 1 day 1..N Methods CYCLE TIME 0.5day 1..N Iterations CYCLE TIME 3 weeks 1..N Questions 1..N Increments CYCLE TIME CYCLE TIME 5 seconds (Not in XP) 2 months

179

(Test(Test-driven development, TDD)


( ) ! : Pair Programming : Pair Programming , customer) : (1 5,5 ) : 1 ( N-1 N,

(on-site

(Cont.)


TestTest-driven development (TDD) test case, test code, test tool TDD (check) (review) Test :

181

(Cont.)
O-O class class ?

182

* * ,Cockburn Csikszentmihalyi , flow( )


183

Csikszentmihalyi

[t

:k's ntmiha: i] *

: (good work)

(extreme)
* Csikszentmihalyi, Creativity: From Flow Experience to Good Work, , Nov. 29, 2006.

184

1.

Clear goals in

every step of the way. 2. Immediate feedback to ones action. (1)(2) 3. ( ) Balance between challenges and skills. (3)
( A,B,C,D E) E (flow, extreme) extreme)
185

C A

186

(Good work)
(productive activity): 1. ( craftmanship) (meet the requirements of the craft) 2. (socially useful and valued) 3. (personally rewarding)
187

Attention is focused on a limited stimulus field. Full concentration and complete involvement.

: (Concentration is like breathing: you never think of it) !


188

There is freedom from worry about failure. : .. :

189

Sense of time distorted. : (1) (2)


190

m :

* XP sustainablePace

!
191

192

*
** : 1) : 2) :
* ** ,

(
,

,2006. scenario
193

: 1) 2) 3)

 

194

(Cont.)


195

(Cont.)
  

:
[ 2009 ]

196

1) 2) 3) API (application program interface)


197

1) 2) 3)

4)
198

199

* myAgile
  

: (2 pairs) run myAgile

1. 2. 3.

200

myAgile
myAgile (Extreme Programming, XP) ( ) -

( 100 ) (organizational breakdown) ( 10 10

)
201

myAgile
* 0.  1.  2.  3.  4.  5. * 6. * 7.  8.  9. * 10. (*

(11

(Exploring requirements) (Scenario) (Acceptance test case) (CRC session) (Dispatching and Scheduling) (Unit test code) (Data Structure Design) (Algorithm Design) (Coding) (Unit & Acceptance testing) (Reverse Engineering Tool) 4 , 7 Extreme Programming)

myAgile

203

myAgile
Java,C++,C# (mark(mark-up language) agent :C/C++ O-O , semanticWeb) ontology,

,C# Java;Java agent( Java!


204

0. * (Exploring requirements)
: 1. : ( 2. 3. 4. ) (2) ( ) ( ) ( ) ( )

* Gause and Weinberg, Exploring requirements, requirements, , 2007.


205

0.
5. : feature ( attribute ( constraint( preference( ) 6. : : : :

(Cont.)

) ) 1.75 ) 1 0.05

206

1.

(Scenario)
(on(on-site usage expert)( ( feature) A4 )

normal) (exceptional) scenarios file

editor : password

1. 2. *

welcomeScreen ( mainScreen (

)* )*

207

1.


(Cont.)

(Flow Chart) (pseudo code)

) (

( if then else then else)

208

2. (Acceptance test case)


, , ; (acceptance test case) : welcomeScreen password data ,
209

mainScreen *JFK2008 exact data , data data file.

3.
(

(CRC Session)
CRC(Class,Responsibility, Collaborator)

) (partition) , (object) (object interaction method) (hidden objects), (CRC card, A4 ) 1.Class name (C), 2. Responsibility (R),( method) 3. ( responsibility) Collaborator (C) CRC cards class encapsulation, (3) (class interfaces) (1)(2) class use relationship

210

3.
1. accep. test case object object A4

(Cont.)
: method method

2.

class methods class ( CRC) 3. A4 ( classes ) class interfaces ( ) 4. method header (method description, parameters, return value, exceptions) 1.parameters 5 (magic 7 minus 2) 2.return value object, class 3. global variables
211

3.
CRC , user (hidden objects,

(Cont.)
(partition) )
**

:
*

* * Scenario ** : John, Mary , O-O , class,object method method

parameter

212

3.
:

(Cont.)
; ;

class class class ; ..... .

{..}; {.. ( {..

)};

( .

); ( );
213

3.
: User Story ( Scenario : Use Case : ( ) :

(Cont.)

214

, , * ** ( ), *** * The method gets two input arguments. ** then, it executes the method, *** finally, it sends return value.
215

: O-O !

teamwork class, public method class interface (header)


216

Class Interface
1. class names, method names (O(O-O) names O-O ! class

2.

Class interface

class header method headers


217

Class Interface
Selection Sort class interface : public class mySort { /* data structure ( )*/ public mySort (int inputArray[]){ } public int [] sort () {} } // end of mySort method interface
218

: 1. 2. 3. 4. class names, public method names ( ) names class names 100 names

80 O-O 80%

219

?
(domain knowledge)

(domain experts)
class Names BalanceSheets, Accounts ; Object Name sep09Account; method Names debit , credit
220

Interface and Header (


Class interface and method interface ,

Header (

221

(header)


open source (reuse code) (developed code) 1) ( ) 2) (Big O time estimate) (small project size, team size) (big problem size)
222

(Cont.)


( )

 

223

Interface
, , : , : , , debug source code, : API (application program interface) header
224

Header(
Header
, ,2006] [

)
,R. Williams

: (

1. 2. 3. 4. 5.

( (

) )
225

Header(

/* method subString ---------------------------------------------* A String object method indexes * * @param beginIndex index ( index) * @param endIndex index ( index) * @return beginIndex endIndex * * @throws IndexOutOfBoundsException * if beginIndex or * beginIndex endIndex or * endIndex length() * * Time estimate : O (n) * Example: helloworld.subString(3,6) ; low -------------------------------------------------------------------------*/ public String subString (int beginIndex, int endIndex)

226

/* class EventDetectionThread ----------------------------------* * thread detector, start , 0.5 (500 ms) ./buffer (fetch) event information(.xml) path * observer ( event parser) path. * , null. * * Example: * ./buffer event information: * * 091123153040000.xml ( ) year09 mon11 day 23 * 091123153040500.xml * 091123153041000.xml ( ) * * detector 091123153040000.xml

*------------------------------------*/
: detector=new EventDetectionThred(); abstract

1)scenario, 2)acceptance test case, 3) ( ) 4) (maintenance guide): acceptance test case method source code file method header pseudopseudo-code source code
228

accep. test cases case : method 1 (source code file) method 2 (source code file) case : method 1 (source code file) method 11 (source code file) method (source code file) method 12 (source code file) method 2 (source code file)
229

(architect) class diagram unified modeling language (UML) Rational Rose


: ( )

230

(Cont.)
:
class class { { } =new ();

class diagram ! design pattern, component ?


231

:
(inherite)

class diagram
;1 (use)1

232

(Cont.)
{ public class {} class {private boolean ; public void ( ) {/* */ = . =new (); =new (); 1 = new ( ); 2 = new . ( 1) ; . ( 2) class diagram classes:
233

class class

extends

{ the extended data and methods} =new () ; int ; boolean ( ) {} }

( ); } ( );

(Cont.)
; ;

e e
234

(Cont.)


: : : ? O-O !

( ( )

235

4.


(class interfaces) class ( : )

*
* l k
236

Cockburn, Agile Software Development, p.86, p.86, AddisonAddison-Wesley, 2002.

237

4.
Release (

(Cont.)
vs.Iteration j *) (pace) (strong heart-beat) heart(methodology tune-up) tune ) **

(
* Ruby/PHP( ** (

Java) evolve)
238

Release Iteration

Increment

1 1

2 1+ 2= 2

239

5.
class

(Unit test code)

public method ( unit) (test cases) ( null input) ( exceptions handle ) (input) (expected output) (unit test case) (test code)

240

Test Code Example


//Test Case 1 input {3,1,4,2} expected output {1,2,3,4} public void testSort1() { /* input expected , result int input[] = {3,1,4,2},expected[] = {1,2,3,4}; int result[]; /* new mySort mySort obj = new mySort(input); /* sort */ result = obj.sort(); input */ */

/* assert equal */ assertEquals (toString(result), toString(expected)); }


241

Test Cases As Test Code Header


//Test Case 1: input {3,1,4,2} expected output {1,2,3,4} //Test Case 2: input {1,1,1,1} expected output {1,1,1,1} //Test Case 3: input {3,2,4,2} expected output {2,2,3,4} public void testSort1() { /* input expected , result int input[] = {3,1,4,2},expected[] = {1,2,3,4}; int result[]; .. public void testSort2() { public void testSort3() {

*/

242

More on Test Cases


O-O : o2 = o1.m1(p1,p2) *

input parameters (p1,p2), output object (o2) , , test case o1 (object 1) , setter object data value *
, arguments, method parameters
243

More on Test Cases (Cont.)


:
/* a,b,

method interface:
*/public int add (int a,b) {}

1.a,b

, ,
, ) , )

Case 1: a is 1, b is 2 ( Case 2: a is 1, b is 0 (

2. 3. 4.

9 test cases test code source code { return a+b;} Junit test code source code
244

6. (Data Structure Design)




class public methods

class data

highhigh-level data structure lowlow-level data structure

tree array

245

6.

(Cont.)

Java Collections Framework (JCF) * classes 1.List <1,2,3>: ArrayList, LinkedList 2.Set {3,1,2}: TreeSet, HashSet 3.Map {1->a,2->b,3{1->a,2->b,3->a}: TreeMap, HashMap Heap, PriorityQueue ( Network) JCF method Big O method Big O for each i 1 N call TreeSet method with O(logN) end for
* Collins,Data Structures and the Java Collections Framework, Collins,Data McGrawMcGraw-Hill, 2005.
246

An Example
:

10.0 7.4

8.3

20.0 14.2 15.0


247

adjacencyMap
0 null 0 hash 17 68899 key value null next null to 20.0 29
-303674281

distance next 15.0 null

null

57

2599292 10.0

null

null 7.4 14.2 null

85

72266597

null

95

2390765

null

100

8.3

null

Java data structure


protected HashMap <Houses, LinkedList <NeighborDistances>> adjacencyMap; protected Houses protected NeighborDistances ; 14.2;

249

6.


(Cont.)

(array)

250

7.
sketch) (pseudo code)

(Algorithm Design)
(design

(abstraction levels) trace test case debug (time estimate) O(n3) private method ( (group review) )
251

Why
XP : 1. ( 2. (design sketch)

t (pseudo code) ( Java file) t (flow chart)

252

Design Sketch


design sketch
0 3 0 1 1 1 .. .. 2 4 nn-1 2 n-1 2

select

min 0

1 .. n( i ) ..2 3 4

0 1

1 .. n( i ) .. 2 3 4

n-1 2

select 1

min i ~ n-1

0 1

1 2

..

.. n-2 ( i ) 4

n-1 3

n-2
0 1 1 2 .. .. 2 3 nn-1 4

sort

253

Design Sketch (Cont.)


design sketch design sketch pseudo code Sketch load) design sketch : ( ( ) ) (cognitive

254

Design Sketch (Cont.)


(sketch) ( //TODO //?? )

255

Pseudo code
Pseudo code x  (English Term) ( class name method name
 

variable name

( x )

array [i..N-1] [i..N-

min
256

(English Term)


review

257

Class, object, variable


class object object symbolTable ( Desks) ( myDesk) aSymbolTable

Method
boolean buy (Desks myDesk) boolean buy (Tables hisTable) methods
258

(Cont.)
(sticky )

: WT0820 : TW2008

Oleogg Crosmioft Google Microsoft


259

(Cont.)


WT0820 TW2008

(stickiness) TW2008 : 1. TAIWAN (TW) 2. WT0820

2008

260

Pseudo code
1. Sequence
1. 2.

:
select min

array[i..Narray[i..N-1]

1.

2.

sequence

1.

2. Selection
if

:
then min else null end if

j min case .. end case

3. Iteration

:
then min end if

for j from i+1 upto N-1 if j min end for while .. end while

261

Pseudo Code
1. 2. . . if then else case while for each end if end case end while end for from upto downto by

call null <= ( a<=1 means set a to 1) //?? //TODO ( ? coding) coding)

TODO

data (

method) names
262

Pseudo Code (Cont.)


Pseudo Code levels)
1. 2. 3. test case trace

(abstraction

263

Trace to Debug (
Trace pseudo code trace pseudo code coding, , source code work ,

Trace (Trace to Debug)

source code

BUG!
264

Trace to Debug (Cont.)


: ( ( (relax) ) )

(BUG!) trace Compiler Project project BUG!


265

Trace to Debug (Cont.)


:

( ) (Flow)
266

Trace to Debug (Cont.)


Trace

pseudo code source code

267

7.


(Cont.)
trace to

debug : ( data ) class

268

7.


(Cont.)

: Java code

269

: public Entry findMin (root) : binary search tree : input 5; expected output 2 : 5
3 2 4 entry element
270

):

1. root 2.return

(Cont.)
array findMin min array for each array if min then min end for min heap min array findMin :

min

, , : a,b,c 100 data a if b min then min b if c min then min c (100(100-1) !

findMin:

271

7.
open source

(Cont.)

open source reused open source unit OK )

bug test code (


272

open source

7.


(Cont.)

: waterfall

273

Class Interface & Data Strucure


class Adjacency protected HashMap <Houses, LinkedList<NeighborDistances>> void void showAllAdjacencies showNames (Houses

adjacencyMap; theHouse)

(HouseList houseList)

274

/*------------------------------------------------------------------------------/*------------------------------------------------------------------------------* showAllAdjacencies theHouse ( ) * * @param theHouse house * Time estimate: O(n2) * : theHouse , ( ) ( ) --------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------*/

public void showAllAdjacencies (Houses theHouse) 1. toHousesList <= getToHouses(theHouse) 2. toHousesList showNames(toHousesList) 3. fromHousesList <= getfromHouses(theHouse) 4. fromHousesList showNames(fromHousesList)

O(n)

O(n2)

275

(Cont.)
/*-------------------------------------------------------/*-------------------------------------------------------* showNames houseList * * @param houseList * Time estimate: O(n) --------------------------------------------------------*/ --------------------------------------------------------*/

private void showNames (HouseList houseList) for i from 0 upto houseList -1 houseList i end for

276

8.
 

(Coding)
( /* */)

( Java, C#,C Ruby/PHP

277

/*-------------------------------------------------------/*-------------------------------------------------------* showNames houseList * * @param houseList * Time estimate: O(n) --------------------------------------------------------*/ --------------------------------------------------------*/ private void showNames (HouseList houseList) /*for i from 0 upto houseList -1 */
for(i=0, i<=length(houseList-1), i++); i<=length(houseList-

/* houseList /*end for */

*/println

houseList(i).name);

:
278

9.

(Unit testing)

(unit, Java public method source code) ( JUnit) test code (unit)

279

280

10.
AgileJ (source file reused code) class diagram, sequence diagram class classes main program : ) CMMI process areas goals

281

10.

(Cont.)

coding source code source code class diagram

class diagram source code


282

Class diagrams generated by tool

283

Sequence diagram generated by tool

284

myAgile
myAgile CRC, test code, pseudo code coding 1) CRC test code 2) pseudo code (refactor) CMMI 3)
285

myAgile


(Cont.)

(pair) header pseudo code Java code 15 Java code


286

myAgile
: , , ? , : , , , , , , , ,

(Cont)
, , , ,

, ,
287

myAgile
ATM , : scenarios cases ,

(Cont)
, myAgile

acceptance test !
288

289

Selection Sort
:

Test Case, Test Code, Design Sketch, Pseudo Code, Maintenance.


290

Test Case


Creating unit test cases


PostPost-condition PrePre-condition
1. 2. 3.

291

Test Case (Cont.)




test cases
1.
 

Input {3,1,4,2} Expected Output {1,2,3,4} Input {1,1,1,1} Expected Output {1,1,1,1} Input {2,2,3,1} Expected Output {1,2,2,3}
292

2.
 

3.
 

Test Code

(header) (header)

/* test code: testMySort.java source code: mySort.java 2011.4.1 test case 1: {3,1,4,2} ->{1,2,3,4} test case 2: {1,1,1,1} ->{1,1,1,1} test case 3: {2,2,3,1}-> {1,2,2,3} {2,2,3,1}*/ test code test code, source code
293

Test Code
// Java Test Code (C# test code import junit.framework.*; public class TestmySort extends TestCase { public TestmySort (String s) {super(s);} /* /* /* test cases test cases test case public void */ protected void setUp (){} */protected void tearDown (){} test method */ public void testSort () {} } )

294

Test Code (Cont.)


// Java Test Code //Test Case 1 input {3,1,4,2} expected output {1,2,3,4} public void testSort1() { /* input expected , result int input[] = {3,1,4,2},expected[] = {1,2,3,4}; int result[]; /* new mySort mySort obj = new mySort(input); /* sort */ result = obj.sort(); input */ */

/* assert equal */ assertEquals (toString(result), toString(expected)); }


295

Test Code (Cont.)


// Test Case 2 input {1,1,1,1} expected output {1,1,1,1} public void testSort2() { int input[] = {1,1,1,1}, expected[] = {1,1,1,1}, result[]; mySort obj = new mySort(input); result = obj.sort(); assertEquals (toString(result), toString(expected)); }


Test Cases

Test Code
296

Test Code (Cont.)




test cases 5 unit (method) (cases) 43=64 cases test code case

10

test code

source code
297

Pseudo Code
1.
1. 2. 3. select min

select min (repeat) (until)

2.
repeat 1. 2. until ( 0 ~ n-1) n( ( select min 0) 1 ~ n-1) n( n-2)
298

Pseudo Code (Cont.)


 

: array for loop : i 0 array[0..Narray[0..N-1] i 0 array[i..Narray[i..N-1] repeat until for each


// for i from 0 upto N-2
1. 2. array[i..Narray[i..N-1] select min ( arry[i]) arry[i] )

(i)

end for

299

Pseudo Code (Cont.)


3.
sort: sort array for i from 0 upto N-2 1.min( ) array[i..Narray[i..N-1] ( arry[i]) arry[i]) 2. array[i..N-1] select min array[i..Nfor j from i+1 upto N-1 if j min end for then min end if

min arry[i]) ( arry[i]) end for

3.

array[i..Narray[i..N-1]
300

Coding
 

Java source code Class mySort integer input array


public class mySort { /* data structure */ private int array []; /*constructor*/ {/*this array

constructor

public mySort (int inputArray[]) input array*/this.array = inputArray;} array*/this.array inputArray;} public int[ ] sort ( ){ }

}// end of mySort


301

Coding (Cont.)
/* sort: sort array */ sort ( ) { /* for i from 0 upto N-2 */ for (int i = 0; i <= array.length-2; i++) { array.length/*1.min( ) array[i..Narray[i..N-1] ( array[i])*/ int min=i; array[i])*/

/*2. array[i..N-1] select min */ array[i..Narray.length/*for j from i+1 upto N-1*/ for (int j = i + 1; j <= array.length-1; j++) N/*if /*if j min then min end if*/ if (array[j] < array[min]) min = j; //end for //end /*3. /*3.
//end for

min

array[i..Narray[i..N-1]

( array[i])*/ swap (i,min);} array[i])*/

302

Coding (Cont.)
Coding pseudo code source code source code PseudoCoder )

pseudo code source code ( pseudo code

303

Coding (Cont.)


:


? 1. 2. 3. ( )

304

Coding (Cont.)
swap method coding coding private method pseudopseudoprivate method test code

/*swap: i1, i2 */ private void swap (int i1, int i2) {int temp = this.array[i1]; this.array[i1] = this.array[i2]; this.array[i2] = temp; }
305

Unit Testing (Cont.)


JUnit http://www.junit.org/index.htm (a) source code: mySort.java test code: TestmySort.java (b) javac *.java

306

Unit Testing (Cont.)


(c) java junit.swingui.TestRunner TestmySort

307

Unit Testing (Cont.)


(d) Test Cases

308

Unit Testing (Cont.)


test case1 public void testSort1() { int input[] = {3,1,4,2}, expected[] = {2,1,3,4}; // int result[];

1, 2, 3, 4

mySort obj = new mySort(input); result = obj.sort(); assertEquals (toString(result), toString(expected)); }


309

Unit Testing (Cont.)


TestmySort : 1,2,3,4 test case 1 : 2,1,3,4 ! Testing :

310

Unit Testing (Cont.)

  

Test case 1 Test case 2 Test case 3

311

Maintain
Selection Sort 1. 2. 3. 4. maintenance request :

test case code ( input 3142, expected output 4321) pseudo code pseudo code source code unit testing tool testing
312

Maintained pseudo and source code


/* sort: sort array // for i from 0 upto N-2
for (int i = 0; i < =array.length-2; i++) { =array.length-

*/

sort ( ) {

//1.max(

array[i..Narray[i..N-1]

( array[i] ) array[i])
int max=i;

// 2. array[i..N-1] select array[i..N// for j from i+1 upto N-1

max

for (int j = i + 1; j <= array.length-1; j++) array.length-

//if //end for


//3. //3. max

max

then

max

end if

if (array[j] > array[max]) max = j;

array[i..Narray[i..N-1]

( array[i] ) array[i])
swap (i,max);}

//end for
313

Insertion Sort Shell Sort


design sketch, pseudo code, source code.

314

Insertion Sort Design Sketch


sort sort
sort 9 0(i) sort 9 0 6 1 3 2 sort 4 sort 9 1 3 2(i) 4 1 n-2 2 n-1 4 1 n-2 2 n-1

sort sort

sort

6 1(i)

3 2

1 n-2

2 n-1

sort 9

Insert
sort 6 0

i..n-1 sort i..n-1 insert

sort 6 sort

sort

n-1
sort 1 0 2 1 3 2 4 6 n-2 9 n-1

sort

315

Insertion Sort Pseudo Code


public int[] insertionSort() /* integer array input sort integer array ouput sort integer array */ 1.for i from 1 upto N-1 Nsort array[0..i] sort for j from i downto 1 if array[j]< then swap else insert end if end for end for 2.return array 2009.5.13

sort array

316

Insertion Sort source code


public int[] insertionSort(){ /*1.for i from 1 upto N-1 Narray[0..i] sort* sort*/
for (int i=1; i<=array.length-1;i++){ i<=array.length-

sort

sort array

/* for j from i downto 1 */


for (int j=i; j>=1;j--){ j>=1;j--){ /*if array[j]< then swap */ if (array[j]<array[j-1]) swap(j,j-1); (array[j]<array[jswap(j,j/*else insert end if*/else break; } } if*/else // end for // end for /*2*/ return array;}

317

Shell Sort Design Sketch


Shell sort increment increment
increment = 2 0 1 9 6 0 1 0 1 0 0 1 0 1 6 1 1 2 1

insertion sort insert

sort

0 3 2 0 3 2 0 3 2

1 4 1 4 1 4

0 1 n-2 0 9 n-2 0 9 n-2

1 2 n-1 1 2 n-1

increment( 2) increment

(
1 6 n-1

0 ( 1, 3, 9)

insertion sort

increment
increment = 1 0 0 1 2 0 1

increment/2 increment 1

0 3 2

0 4

0 6 n-2

0 9 n-1

sort
318

Shell Sort Design Sketch (cont.)


( design sketch )

1. increment 2 array : k=1: {9 3 1} k=2: {6 4 2} insertion sort 2. shell sort increment 1 ( insertion sort)

319

Shell Sort pseudo code


public int[] shellSort (int increment) 1.for k from 1 upto increment, insertion sort for i from 1+k upto N-1 by increment, Narray array sort for j from i downto 1+k by increment if array[j] < then swap else end if end for end for end for 2. shell sort increment 1
320

3. return array

Shell Sort source code


public int[] shellSort (int increment) { /*1.for k from 1 upto increment,
for (int k=1; k<=increment; k++){

insertion sort*/ sort*/

/* for i from 1+k upto N-1 by increment, Narray sort*/


for (int i=1+k; i<=array.length-1; i=i+increment;){ i<=array.length-

array

/* for j from i downto 1+k by increment */


for (int j=i; j>=k+1; j=j-increment;){ j=j-

/*if array[j]<

then swap

*/

if (array[j]<array[j-increment]) swap(j,j-1); (array[j]<array[jswap(j,j/* else end if*/else break; } } }

//end for //end for // end for /*2. shell sort increment 1*/

if (increment >=1) array=shellSort(increment/2);

/*3*/ return array;}


321

(agile) driven development, TDD) ( ) (Test(Test-

322

323

324

C# Unit Testing
// C# test code using NUnit.Framework; /* TestmySort Class [TestFixture] public class TestmySort { /* TestCase [Test] public void testCase1(){} }
325

Class* Class*/

public method

[Test]*/

C# Unit Testing (Cont.)


//Test Code //Test Case 1 input {3,1,4,2} expected output {1,2,3,4} [Test] public void testCase1(){ /* input expected , result */ int[] input={3,1,4,2}; int[] excepted={1,2,3,4}; int[] result=new int[4]; /* new mySort mySort obj= new mySort(input); /* sort */ result=obj.Sort(); input */

/* assert equal */ Assert.AreEqual(result,excepted); }


326

C# Unit Testing (Cont.)


Test Case 2 input {1,1,1,1} expected output {1,1,1,1}

[Test] public void testCase2(){ int[] input={1,1,1,1}; int[] excepted={1,1,1,1}; int[] result=new int[4]; mySort obj= new mySort(input); result=obj.Sort(); Assert.AreEqual(result,excepted);} Test Cases Test Code
327

C# Unit Testing (Cont.)


 

UltraEdit http://ape.csie.ncu.edu.tw/cuedit920a.exe cuedit920a.exe

328

C# Unit Testing (Cont.)


  

UltraEdit Universal User

329

C# Unit Testing (Cont.)


Testing ( NUnit) (a) UltraEdit csc /t:library /r:( /r:( %p http://www.nunit.org/index.php?p=download > )\bin\nunit.framework.dll %n%e bin\ NUnitC#

330

C# Unit Testing (Cont.)


 

(b) mySort TestmySort >NUnitC#

(mySort.cs) mySort.dll

331

C# Unit Testing (Cont.)




(c)

NUnit

File>open

mySort.dll

TestmySort class TestCases

332

C# Unit Testing (Cont.)




(d)

TestmySort

Run

Testing

333

C# Unit Testing (Cont.)




TestCase

334