Agile%20Software%20Development - PowerPoint PPT Presentation

About This Presentation
Title:

Agile%20Software%20Development

Description:

* Institute of Computer Software Nanjing University * Agile Processes SCRUM Crystal ... Document presentation ... Strategy Pattern Template Method Pattern ... – PowerPoint PPT presentation

Number of Views:251
Avg rating:3.0/5.0
Slides: 119
Provided by: zf1
Category:

less

Transcript and Presenter's Notes

Title: Agile%20Software%20Development


1
Agile Software Development
  • ??????

2
??
  • Introduction
  • Agile Development
  • Agile Design

3
??
  • Introduction
  • Agile Development
  • Agile Design

4
Introduction
  • Robert C. Martin Agile Software Development
    Principles, Patterns, and Practices, Prentice
    Hall (October 25, 2002)

Jolt Award 2003
5
Introduction
  • Robert C. Martin

Designing Object Oriented C Applications using
the Booch Method , 1995 Pattern Languages of
Program Design 3, 1997
More C Gems, 1999
Extreme Programming in Practice, 2003 UML for
Java Programmers ,2003
Uncle Bob
http//www.objectmentor.com
6
Agile ??
  • ??????????????????????????
  • ????????????? -- practice
  • ??????????????? -- principle
  • ??????????? -- pattern
  • ??????????,???????

7
The Agile Alliance ????
  • The Manifesto of the Agile Alliance ??????, 2001

http//www.agilealliance.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 documentation
  • Customer collaboration over contract negotiation
  • Responding to change over following a plan

Kent Beck, Alistair Cockburn, Robert C. Martin,
etc.
8
??????
  • ????????????
  • ????????????????
  • ??????????
  • ??????????

9
Principles
  • ?????????????????????????????????
  • ?????????,???????????????????????????
  • ?????????????,????????????????,????????????

10
Principles
  • ?????????,????????????????????
  • ?????????????????????????????,?????????????
  • ?????,??????????????????,?????????

11
Principles
  • ????????????????
  • ?????????????????????????????????????????????
  • ???????????????????????

12
Principles
  • ?????????????????????
  • ???????????????????
  • ??????,????????????????????,????????????????

13
Agile Processes
  • SCRUM
  • Crystal
  • Feature Driven Development ????????
  • Adaptive Software Development ???????
  • eXtreme Programming (XP) ????

14
??
  • Introduction
  • Agile Development
  • Agile Design

15
Agile Development
  • Extreme Programming(XP,????) ?????????????,???????
    ?,????????,?????????????????????
  • XP??????,????????????????????
  • XP??team work??????,??,?????????????,????????????,
    ???????,???????????????

16
Extreme Programming
  • XP??4???
  • ??(communication),XP???????????????????????
  • ??(simplicity),XP????????????
  • ??(feedback),????????,?????????????
  • ??(courage),??????????????

17
Extreme Programming
  • XP??????????????,??????????????????,??????????????
  • XP????????????,?????????????????,XP????????
  • XP???????(???),???2-12???,XP???????????

18
Practices of XP
  • ????????
  • ???? user stories
  • ?????
  • ????
  • ????
  • ????
  • ???? pair programming

19
Practices of XP
  • ????????? Test-Driven Development
  • ?????
  • ????
  • ????????
  • ???????
  • ???? planning game
  • ?????
  • ?? Refactoring
  • ?? Metaphor???????????????

20
??
  • Introduction
  • Agile Development
  • Agile Design

21
What is Design?
  • After reviewing the software development life
    cycle as I understood it, I concluded that the
    only software documentation that actually seems
    to satisfy the criteria of an engineering design
    is the source code listings.
  • -- Jack Reeves

22
Design Smells
  • Rigidity ??? ? ????
  • Fragility ??? ? ????
  • Immobility ??? ? ????
  • Viscosity ??? ? ????
  • Needless Complexity ???????
  • Needless Repetition ??????
  • Opacity ???

23
The Copy Program
  • Initial Design

void copy() int c while ((cRdKbd())!
EOF) WrtPrt(c)
24
Requirement changes
  • bool ptFlag false
  • //remember to reset this flag
  • void Copy()
  • int c
  • while ((c(ptFlag?RdPt() RdKbd())!EOF)
  • WrtPrt(c)

25
Requirement changes again!
bool ptFlag false bool punchFlag
false //remember to reset these flags void
Copy() int c while ((c(ptFlag?RdPt()
RdKbd())!EOF) punchFlag ? WrtPunch(c)
WrtPrt(c)
26
Agile design of the copy example
  • int RdKbd()
  • void WrtPrt(int)
  • const int EOF -1
  • class Reader
  • public virtual int read() 0
  • class KeyboardReader public Reader
  • public virtual int read() return RdKbd()
  • KeyboardReader GdefaultReader
  • void Copy(reader reader GdefaultReader)
  • int c
  • while ((creader.read()) ! EOF)
  • WrtPrt(c)

27
Agile developers
  • Knew what to do because
  • Detect the problem by following agile practices
  • Diagnose the problem by applying design
    principles
  • Solve the problem by applying the appropriate
    design pattern
  • The interplay between these three aspects of
    software development is the act of design.

28
A more complex example Multi-panel interactive
systems
  • ??
  • ????
  • ??????
  • ???????
  • ??

28
29
Multi-panel interactive systems
  • ??
  • ????
  • ????(session)???????
  • ????
  • ??panel(???),??????(??),????,???,????????????????
    ???(????????????????)
  • ????
  • ??
  • ????

29
30
2019/7/10
Institute of Computer Software Nanjing University
31
?????
32
????
  • ?????
  • ?????
  • ?????

?????????? (????)????? ?????
33
A Simple-minded solution
34
A Simple-minded solution
  • ??
  • Goto!
  • ??
  • ????????hardwired?????????
  • ???????????
  • ?????

34
35
A functional, top-down solution
  • ?,????goto,????????,??????? transition(state,choi
    ce)

35
36
(No Transcript)
37
Top-down decomposition
38
The top
39
(No Transcript)
40
Critique
41
(No Transcript)
42
Fragileness
???????
???????????
43
object-oriented architecture
  • Law of inversion
  • If your routines exchange too many data, put your
    routines in your data.

44
State as a class
45
(No Transcript)
46
Use inheritance and deferred class
47
(No Transcript)
48
(No Transcript)
49
(No Transcript)
50
(No Transcript)
51
(No Transcript)
52
The system? An ADT, not a main function
53
(No Transcript)
54
2019/7/10
Institute of Computer Software Nanjing University
54
55
(No Transcript)
56
(No Transcript)
57
(No Transcript)
58
??
  • Focus on data abstraction
  • Forget the main function of the system,
    resist the constant temptation to ask What does
    the system do?
  • Law of inversion
  • Realworldliness is not a significant difference
    between OO and other approaches what counts is
    how we model the world

59
??
  • Introduction
  • Agile Development
  • Agile Design
  • design principles

60
Design Principles
  • SRP (The Single-Responsibility Principle) ??????
  • OCP (The Open-Closed Principle) ??-????
  • LSP (The Liskov Substitution Principle)
    Liskov????
  • DIP (The Dependency-Inversion Principle) ??????
  • ISP (The Interface-Segregation Principle) ??????

61
SRP ??????
  • A class should have only one reason to change.
    ??????,???????????????
  • What is a Responsibility?
  • A reason for change ???????????????????,??????,???
    ??????????
  • An axis of change is an axis of change only if
    the changes actually occur. ??????????????????????
    ?

62
Example
??????
????
63
Example applying SRP
??????
??????
64
Example SRP violation
  • interface Modem
  • public void dial (String pno)
  • public void hangup()
  • public void send (char c)
  • public char recv()

connection management
data communication
65
Example
  • Separated modem interface

????????????????????????,?????????!
66
OCP ??-????
  • Software entities (classes, modules, functions,
    etc.) should be open for extension, but closed
    for modification. ????(????????)????????,????????
  • OCP is the heart of OO design!

67
OCP Description
  • Two primary attributes
  • Open for extension the behavior of the module
    can be extended
  • Closed for modification extending the behavior
    of a module does not result in changes to the
    source or binary code of the module.
  • ??????,???
  • Is it possible?

68
Abstraction is the key!
Client is neither open nor closed
69
Strategy Pattern
Client is both open and closed
70
Template Method Pattern
A clear separation of generic functionality from
the detailed implementation of that functionality
71
Shape????
  • ???????

--------drawAllShape.cc--- typedef struct Shape
ShapePointer void DrawAllShapes(ShapePointer
list, int n) int i for (i0iltni)
struct Shape slisti switch
(s-gtitsType) case square
DrawSquare((struct Square)s) break
case circle DrawSquare((struct Circle)s)
break
--------shape.h---------- enum ShapeTypecircle,sq
uare struct Shape ShapeType
itsType --------circle.h--------- struct
Circle ShapeType itsType double itsRadius
Point itsCenter --------square.h--------- str
uct Square ShapeType itsType double
itsSide Point itsTopLeft
72
??OCP
  • OOD????

class Shape public virtual void Draw()
const0 class Squarepublic Shape
public virtual void Draw() const class
Circlepublic Shape public virtual void
Draw() const void DrawAllShapes(vectorltShape
gt list) vectorltShapegtiterator I for
(ilist.begin()i!list.end()i)
(i)-gtDraw()
73
??100??!
  • ???????????????????,???
  • ?????????,?????????????!

74
Heuristics
  • OCP????????????!
  • ?????????????
  • ??OOPL??????OCP
  • ????????????
  • 100??????,?????????????
  • ????????????????????,??????????????????

75
LSP Liskov????
76
LSP Liskov????
  • Subtypes must be substitutable for their base
    types. ?????????????????
  • If for each object o1 of type S there is an
    object o2 of type T such that for all programs P
    defined in terms of T, the behavior of P is
    unchanged when o1 is substituted for o2 then S is
    a subtype of T. Liskov88 ??????S???o1,???????T??
    ?o2,???????T?????P?,?o1??o2?,??P??????,?S?T?????

77
LSP Violation (I)
RTTI(???????)
  • struct Shape
  • enum ShapeType square, circle itsType
  • Shape(ShapeType t)itsType(t)
  • struct Circle public Shape
  • Circle()Shape(circle)
  • void Draw() const
  • struct Square public Shape
  • Square()Shape(square)
  • void Draw() const

void DrawShape(const Shape s ) if(s.itsType
Shapesquare) static_castltconst
Squaregt(s).draw() else if (s.itsType
Shapecircle) static_castltconst
Circlegt(s).draw()
78
LSP Violation (II)
class Rectangle public void
SetWidth(double w) itsWidthw void
SetHeight(double h) itsHeighth
private double itsWidth double
itsHeight
IS-A Relationship
79
LSP Violation (II)
  • void SquareSetWidth(double w)
  • RectangleSetWidth(w)
  • RectangleSetHeight(w)
  • void SquareSetHeight(double w)
  • RectangleSetWidth(w)
  • RectangleSetHeight(w)

void f (Rectangle r) r.SetWidth(32) //call
RectangleSetWidth
Square Violated!
Square
80
LSP Violation (II)
Are Rectangle and Square self-consistent?
class Rectangle public virtual void
SetWidth(double w) itsWidthw virtual void
SetHeight(double h) itsHeighth
private double itsWidth double
itsHeight
Square
void g (Rectangle r) r.SetWidth(5)
r.SetHeight(4) assert(r.Area()20)
True or false?
Violated!
81
The real problem
  • Validity is not intrinsic! ?????????
  • ????????????????????
  • IS-A is about Behavior
  • Behaviorally, a Square is not a Rectangle.
  • Recall DbC principle about inheritance
  • Precondition ??Postcondition ??

82
The real problem
  • RectangleSetWidth(double w)?????
  • Postcond (itsWidthw)(itsHeightold.itsHeight
    )
  • ??SquareSetWidth(double w)???????
  • ??????????????????

83
Heuristics and Conventions
  • Violation 1
  • Degenerate functions in derivatives ?????????
  • Violation 2
  • Throwing exceptions from derivatives ?????????

public class Base public void f() /some
code/ Public class Derived extends Base
public void f()
84
LSP
  • One of the enablers of the OCP?
  • LSP??OCP????????????
  • It is the substitutability of subtypes that
    allows a module, expressed in terms of a base
    type, to be extensible without modification.
    ?????????????????????????????????????

85
DIP ??????
  • High level modules should not depend on low-level
    modules. Both should depend on abstractions.
    ??????????????,???????????
  • Abstractions should not depend on details.
    Details should depend on abstractions.
    ??????????,??????????
  • Inversion ??????????

86
Laying
  • Booch all well structured OO architectures
    have clearly defined layers, with each layer
    providing some coherent set of services through a
    well-defined and controlled interface.

Unfortunate!
87
Laying
Hollywood principle dont call us, well call
you. ???????????????????????????
  • Inverted layers

also an inversion of interface ownership
????????,??????????????
88
Example
?
Button
Lamp
poll()
turnOn() turnOff()
  • public class Button
  • private Lamp itsLamp
  • public void poll()
  • if (/ some condition /)
  • itsLamp.turnOn()

89
Example
Button
ButtonServer
SwitchableDevice
poll()
turnOn() turnOff()
!
Lamp
  • public class Button
  • private ButtonServer bs
  • public void poll()
  • if (/ some condition /)
  • bs.turnOn()

90
Heuristic
  • Depend on abstractions ?????
  • ????????????????????????????????
  • According to it
  • ???????????????????????
  • ?????????????
  • ??????????????????????????
  • ????????????,??String

91
DIP
  • ???????????????????????
  • ?????????????,??????????,???????????
  • DIP?????OO???????????????????????????????????????

92
ISP ??????
  • Clients should not be forced to depend on methods
    that they do not use. ??????????????????
  • Deals with the disadvantage of fat interfaces
    whose interfaces are not cohesive. ???????????????

93
Example
common door!
class Timer public void Register
(int timeout, TimeClient client )
  • class Door
  • public
  • virtual void Lock() 0
  • virtual void Unlock() 0
  • virtual bool IsDoorOpen() 0

class TimerClient public virtual
void TimeOut () 0
How about a timed door?
94
Interface Pollution
But not all varieties of Door need timing!
95
Separate Interfaces
  • Solution 1 adapter ????????

96
Separate Interfaces
  • class TimedDoor public Door
  • public virtual void DoorTimeOut(int
    timeoutId)
  • Class DoorTimerAdapter public TimeClient
  • pubic
  • DoorTimerAdapter(TimedDoor theDoor)
    itsTimedDoor(theDoor)
  • virtual void TimeOut(int timeoutId)
  • itsTimedDoor.DoorTimeOut(timeoutId)
  • private
  • TimedDoor istTimedDoor

97
Separate Interfaces
  • Solution 2 multiple inheritance

class TimedDoor public Door, public
TimerClient public virtual void TimeOut(int
timeoutId)
98
Heuristic
  • ????????????????????!
  • ???????????????????????
  • ?????,???!

99
Design Principles
  • SRP (The Single-Responsibility Principle) ??????
  • OCP (The Open-Closed Principle) ??-????
  • LSP (The Liskov Substitution Principle)
    Liskov????
  • DIP (The Dependency-Inversion Principle) ??????
  • ISP (The Interface-Segregation Principle) ??????

100
How to design Packages?
  • ?????????????????
  • ????????????????????
  • ??????????(????)????????????(????)?
  • ?????????C?Java????????
  • ?????,????????????

101
?????????
  • REP (The Reuse-Release Equivalence
    Principle),????????,?????????????
  • CRP (The Common-Reuse Principle),??????,??????????
    ???????
  • CCP (The Common-Closure Principle),??????,????????
    ?????????????????

102
REP
  • ?????????,???????????????-- ????????
  • REP??,????????(granule of reuse)???????(granule
    of release)????????????????????????
  • ??????????????!
  • ??????????,??????????????????????????????????????

103
CRP
  • ????????????????,???????????,?????????????
  • ??????????????????
  • ??????????????????????
  • jar??????

104
CCP
  • ??????????????????????????????????????,???????????
    ???,???????????????
  • ???SRP,OCP
  • ????????????????????????????

105
??????????
  • ADP (The Acyclic-Dependencies Principle),??????,??
    ??????????????
  • SDP (The Stable-Dependencies Principle),??????,???
    ?????????
  • SAP (The Stable-Abstractions Principle),??????,???
    ??????????????

106
ADP
  • ?????
  • ????
  • ?????
  • DAG

107
ADP
  • ????????
  • ??MyTasks
  • ??MyDialogs

108
?????
  • ??1 ????????

109
?????
  • ??2 ????????????,????????????

Jitter???
110
Heuristic
  • ????????????
  • ????????????????????
  • ?????????????????????????,??,????????????????

111
SDP
  • ?????????
  • ???????,?????????,?????????????????,??,???????????
    ?

???
??
112
?????
  • (Ca)???????????????????????????
  • (Ce)???????????????????????????
  • ????I 0,1
  • I0 ???
  • I1 ????
  • SDP??????I??????????????I???(?I??????????????)

113
?????
Pa
Pb
q
r
s
Pc
Pd
t
u
v
Pc Ca3, Ce1, I1/4
114
?? vs. ???
  • ?????????????

???HOW TO?
i1
i1
i0
??????
???SDP
115
?? vs. ???
DIP
116
SAP
  • ????????????????
  • ?????????????,????????????????
  • ?????????????,???????????????????????

?????????????!
117
Remember
  • As with all principles, care must be taken not to
    overdo it.

118
?? (????????)
  • ?????????????????
  • ??JDK?Collection??????,?????????????????????????
Write a Comment
User Comments (0)
About PowerShow.com