test driving to clean code kenrick chien cto, critical phase

11
Test driving to clean CODE Kenrick Chien CTO, Critical Phase

Upload: alice-gregory

Post on 04-Jan-2016

223 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Test driving to clean CODE Kenrick Chien CTO, Critical Phase

Test driving to clean CODE

Kenrick Chien CTO, Critical Phase

Page 2: Test driving to clean CODE Kenrick Chien CTO, Critical Phase
Page 3: Test driving to clean CODE Kenrick Chien CTO, Critical Phase

Photo by Toni Blay - http://flic.kr/p/5CNci

Code we want to avoid

Page 4: Test driving to clean CODE Kenrick Chien CTO, Critical Phase

BENEFITS

•Easy to refactor•Cleaner; less time spent debugging•Documentation - examples•More time to do what you enjoy

Page 5: Test driving to clean CODE Kenrick Chien CTO, Critical Phase

THE TDD “CYCLE”

•RED

•GREEN

•REFACTOR

Page 6: Test driving to clean CODE Kenrick Chien CTO, Critical Phase

UNCLE BOB’S Three LAWS OF TDD

1. You are not allowed to write any production code unless it is to make a failing unit test pass.

2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.

3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

Page 7: Test driving to clean CODE Kenrick Chien CTO, Critical Phase

MYTHS

• All about unit tests

• Testing methods, not behavior

• Too slow; I don’t have time for this!

Page 8: Test driving to clean CODE Kenrick Chien CTO, Critical Phase

Limitations•New language /framework•Database & UI•Culture

Page 9: Test driving to clean CODE Kenrick Chien CTO, Critical Phase

Kata

Page 10: Test driving to clean CODE Kenrick Chien CTO, Critical Phase

referencesBeck, K. Test-Driven Development by Example. Addison Wesley, 2003.

Erdogmus, Hakan; Morisio, Torchiano. "On the Effectiveness of Test-first Approach to Programming". Proceedings of the IEEE Transactions on Software Engineering, 31(1). January 2005. <http://iit-iti.nrc-cnrc.gc.ca/publications/nrc-47445_e.html>

Freeman, Steve and Nat Pryce. Growing Object-Oriented Software, Guided By Tests     Massachusetts: Pearson Education, Inc, 2009.

Fowler, Martin. Refactoring: Improving the Design of Existing Code. USA: Addison Wesley Longman, Inc. 1999.

Martin, Robert. Agile Software Development Principles, Patterns, and Practices. New Jersey: Pearson Education, Inc. 2003.

Page 11: Test driving to clean CODE Kenrick Chien CTO, Critical Phase

Contact

• e-mail: [email protected]

• website: http://www.criticalphase.com

• blog: http://geekyninja.blogspot.com

• twitter: @kenrickchien