Writing high quality code for agile2012
Transcript of Writing high quality code for agile2012
7/17/2012
http://ToBeAgile.com 1
Writing High Quality Code
Agile 2012
[email protected] COPYRIGHT © TECHNIQUES OF DESIGN
© Copyright 2009-2012 To Be Agile DB20120717
2
Thank you for being here
7/17/2012
http://ToBeAgile.com 2
3
I am David Bernstein
4
Standing on the shoulders of giants
7/17/2012
http://ToBeAgile.com 3
5
What is quality?
Service Products Software
?
6
What makes software good?
7/17/2012
http://ToBeAgile.com 4
7
Correctness is not enough
8
Remember when?
7/17/2012
http://ToBeAgile.com 5
9
Things change
10
Dealing with change
7/17/2012
http://ToBeAgile.com 6
11
What makes code easy to change?
12
What makes code difficult to change?
7/17/2012
http://ToBeAgile.com 7
13
Code pathologies
14
Rigidity – hard to repurpose
7/17/2012
http://ToBeAgile.com 8
15
Viscosity – difficult to change
16
Complexity – unsure how to change
7/17/2012
http://ToBeAgile.com 9
17
Opaque – difficult to understand
18
Brittleness – expensive to change
7/17/2012
http://ToBeAgile.com 10
19
Pathologies scare us
20
It’s harder on larger projects
7/17/2012
http://ToBeAgile.com 11
21
Quality in software
22
6 software qualities
7/17/2012
http://ToBeAgile.com 12
23
Cohesive
1
24
Language and software
7/17/2012
http://ToBeAgile.com 13
25
Class cohesion
26
Method cohesion
7/17/2012
http://ToBeAgile.com 14
27
Pathologies of poor cohesion
28
Non-redundant
2
7/17/2012
http://ToBeAgile.com 15
29
Finding redundancy
30
Types of redundancy
7/17/2012
http://ToBeAgile.com 16
31
Can non-identical code be redundant?
32
Can identical code be non-redundant?
7/17/2012
http://ToBeAgile.com 17
33
Redundant intent
34
Code investment or debt
7/17/2012
http://ToBeAgile.com 18
35
Pathologies of redundancy
36
Encapsulated
3
7/17/2012
http://ToBeAgile.com 19
37
What can be encapsulated?
38
What you don’t know…
7/17/2012
http://ToBeAgile.com 20
39
…can’t hurt you
40
Encapsulate by policy
7/17/2012
http://ToBeAgile.com 21
41
Optimization
42
Can you encapsulate it?
7/17/2012
http://ToBeAgile.com 22
43
Many ways to encapsulate
44
Pathologies of poor encapsulation
7/17/2012
http://ToBeAgile.com 23
45
Assertive
4
46
Assertive or inquisitive?
7/17/2012
http://ToBeAgile.com 24
47
Object therapy
48
“With great state comes great responsibility”
7/17/2012
http://ToBeAgile.com 25
49
Winston Churchill, Spiderman’s Uncle
50
Pathologies of inquisitiveness
7/17/2012
http://ToBeAgile.com 26
51
Testable
5
52
Testability guides design
7/17/2012
http://ToBeAgile.com 27
53
Pathologies of poor testability
54
Explicit
6
7/17/2012
http://ToBeAgile.com 28
55
Good and bad coupling
56
Bad coupling
7/17/2012
http://ToBeAgile.com 29
57
Coupling
Type
Interface
Abstract
Concrete
58
Coupling example
Type Coupling
Interface Coupling
Abstract Coupling
No Concrete Coupling
7/17/2012
http://ToBeAgile.com 30
59
Pathologies of bad coupling
60
The six code qualities…
7/17/2012
http://ToBeAgile.com 31
61
– Cohesive
– non-Redundant
– Encapsulated
– Assertive
– Testable
– Explicit
62
…spells CREATE
7/17/2012
http://ToBeAgile.com 32
63
Code qualities guide us
64
Thank You!
We have just scratched the surface, to learn more:
– Read my blog: http://ToBeAgile.com/blog
– Follow me on Twitter (@ToBeAgile)
– Attend my one of my Certified Scrum Developer trainings
Public Certified Scrum Developer Essentials classes:
– October 15 – 19, 2012 in Redwood City, CA
Public Agile Software Developer Essentials classes:
– December 10 – 14, 2012 Online (8:00 am-12:00 pm PT)
Private classes available for groups of 8 or more developers
– Learn more at http://ToBeAgile.com