writing high quality code for agile2012.ppt · microsoft powerpoint - writing high quality code for...

32
7/17/2012 http://ToBeAgile.com 1 Writing High Quality Code Agile 2012 DB20111207 www.techniquesofdesign.com [email protected] COPYRIGHT © TECHNIQUES OF DESIGN www.ToBeAgile.com [email protected] © Copyright 2009-2012 To Be Agile DB20120717 2 Thank you for being here

Upload: others

Post on 05-Sep-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 1

Writing High Quality Code

Agile 2012

[email protected] COPYRIGHT © TECHNIQUES OF DESIGN

[email protected]

© Copyright 2009-2012 To Be Agile DB20120717

2

Thank you for being here

Page 2: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 2

3

I am David Bernstein

4

Standing on the shoulders of giants

Page 3: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 3

5

What is quality?

Service Products Software

?

6

What makes software good?

Page 4: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 4

7

Correctness is not enough

8

Remember when?

Page 5: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 5

9

Things change

10

Dealing with change

Page 6: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 6

11

What makes code easy to change?

12

What makes code difficult to change?

Page 7: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 7

13

Code pathologies

14

Rigidity – hard to repurpose

Page 8: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 8

15

Viscosity – difficult to change

16

Complexity – unsure how to change

Page 9: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 9

17

Opaque – difficult to understand

18

Brittleness – expensive to change

Page 10: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 10

19

Pathologies scare us

20

It’s harder on larger projects

Page 11: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 11

21

Quality in software

22

6 software qualities

Page 12: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 12

23

Cohesive

1

24

Language and software

Page 13: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 13

25

Class cohesion

26

Method cohesion

Page 14: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 14

27

Pathologies of poor cohesion

28

Non-redundant

2

Page 15: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 15

29

Finding redundancy

30

Types of redundancy

Page 16: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 16

31

Can non-identical code be redundant?

32

Can identical code be non-redundant?

Page 17: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 17

33

Redundant intent

34

Code investment or debt

Page 18: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 18

35

Pathologies of redundancy

36

Encapsulated

3

Page 19: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 19

37

What can be encapsulated?

38

What you don’t know…

Page 20: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 20

39

…can’t hurt you

40

Encapsulate by policy

Page 21: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 21

41

Optimization

42

Can you encapsulate it?

Page 22: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 22

43

Many ways to encapsulate

44

Pathologies of poor encapsulation

Page 23: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 23

45

Assertive

4

46

Assertive or inquisitive?

Page 24: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 24

47

Object therapy

48

“With great state comes great responsibility”

Page 25: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 25

49

Winston Churchill, Spiderman’s Uncle

50

Pathologies of inquisitiveness

Page 26: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 26

51

Testable

5

52

Testability guides design

Page 27: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 27

53

Pathologies of poor testability

54

Explicit

6

Page 28: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 28

55

Good and bad coupling

56

Bad coupling

Page 29: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

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

Page 30: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 30

59

Pathologies of bad coupling

60

The six code qualities…

Page 31: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

7/17/2012

http://ToBeAgile.com 31

61

– Cohesive

– non-Redundant

– Encapsulated

– Assertive

– Testable

– Explicit

62

…spells CREATE

Page 32: Writing High Quality Code for Agile2012.ppt · Microsoft PowerPoint - Writing High Quality Code for Agile2012.ppt [Compatibility Mode] Author: Administrator Created Date: 7/17/2012

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