Writing high quality code for agile20121. 7/17/2012
Writing High Quality Code
Agile 2012
www.ToBeAgile.com
© Copyright 2009-2012 To Be Agile DB20120717
info@ToBeAgile.com
www.techniquesofdesign.com
info@techniquesofdesign.com COPYRIGHT © TECHNIQUES OF DESIGN DB20111207
Thank you for being here
2
http://ToBeAgile.com 1
2. 7/17/2012
I am David Bernstein
3
Standing on the shoulders of giants
4
http://ToBeAgile.com 2
3. 7/17/2012
What is quality?
Service Products
?
Software
5
What makes software good?
6
http://ToBeAgile.com 3
4. 7/17/2012
Correctness is not enough
7
Remember when?
8
http://ToBeAgile.com 4
5. 7/17/2012
Things change
9
Dealing with change
10
http://ToBeAgile.com 5
6. 7/17/2012
What makes code easy to change?
11
What makes code difficult to change?
12
http://ToBeAgile.com 6
7. 7/17/2012
Code pathologies
13
Rigidity – hard to repurpose
14
http://ToBeAgile.com 7
8. 7/17/2012
Viscosity – difficult to change
15
Complexity – unsure how to change
16
http://ToBeAgile.com 8
9. 7/17/2012
Opaque – difficult to understand
17
Brittleness – expensive to change
18
http://ToBeAgile.com 9
10. 7/17/2012
Pathologies scare us
19
It’s harder on larger projects
20
http://ToBeAgile.com 10
11. 7/17/2012
Quality in software
21
6 software qualities
22
http://ToBeAgile.com 11
12. 7/17/2012
Cohesive
1
23
Language and software
24
http://ToBeAgile.com 12
13. 7/17/2012
Class cohesion
25
Method cohesion
26
http://ToBeAgile.com 13
14. 7/17/2012
Pathologies of poor cohesion
27
Non-redundant
2
28
http://ToBeAgile.com 14
15. 7/17/2012
Finding redundancy
29
Types of redundancy
30
http://ToBeAgile.com 15
16. 7/17/2012
Can non-identical code be redundant?
31
Can identical code be non-redundant?
32
http://ToBeAgile.com 16
17. 7/17/2012
Redundant intent
33
Code investment or debt
34
http://ToBeAgile.com 17
18. 7/17/2012
Pathologies of redundancy
35
Encapsulated
3
36
http://ToBeAgile.com 18
19. 7/17/2012
What can be encapsulated?
37
What you don’t know…
38
http://ToBeAgile.com 19
20. 7/17/2012
…can’t hurt you
39
Encapsulate by policy
40
http://ToBeAgile.com 20
21. 7/17/2012
Optimization
41
Can you encapsulate it?
42
http://ToBeAgile.com 21
22. 7/17/2012
Many ways to encapsulate
43
Pathologies of poor encapsulation
44
http://ToBeAgile.com 22
23. 7/17/2012
Assertive
4
45
Assertive or inquisitive?
46
http://ToBeAgile.com 23
24. 7/17/2012
Object therapy
47
“With great state comes great responsibility”
48
http://ToBeAgile.com 24
25. 7/17/2012
Winston Churchill, Spiderman’s Uncle
49
Pathologies of inquisitiveness
50
http://ToBeAgile.com 25
26. 7/17/2012
Testable
5
51
Testability guides design
52
http://ToBeAgile.com 26
27. 7/17/2012
Pathologies of poor testability
53
Explicit
6
54
http://ToBeAgile.com 27
28. 7/17/2012
Good and bad coupling
55
Bad coupling
56
http://ToBeAgile.com 28
29. 7/17/2012
Coupling
Type
Interface
Abstract
Concrete
57
Coupling example
Abstract Coupling
Type Coupling
Interface Coupling
No Concrete Coupling
58
http://ToBeAgile.com 29
30. 7/17/2012
Pathologies of bad coupling
59
The six code qualities…
60
http://ToBeAgile.com 30
31. 7/17/2012
– Cohesive
– non-Redundant
– Encapsulated
– Assertive
– Testable
– Explicit
61
…spells CREATE
62
http://ToBeAgile.com 31
32. 7/17/2012
Code qualities guide us
63
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
64
http://ToBeAgile.com 32