Your SlideShare is downloading. ×
Test Driven Design by Jonas Auken
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Test Driven Design by Jonas Auken


Published on

Published in: Technology

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. TEST DRIVEN DESIGN AGILE NCR - APRIL 25, 2011 Jonas Auken 1
  • 2. Introduction• Name: Jonas Auken• Role: Agile Evangelist• Primary goal: Excellent quality software• Secondary goal: Happy developers• Means: Agile practices everywhere 2
  • 3. Important questions• How do you know if youre code is working? When you have tested it!• When do you want feedback from your code? Now!• When would you like to refactor? Anytime! 3
  • 4. Agenda• Test driven development• The “Find my Ride” example• Immediate feedback• Comfortable refactoring• Towards a better design• Discussion: How do we get started? 4
  • 5. @Test public void canInspirePeopleToDoTDD() { agileNCR.arrangeConference(2011); People people = agileNCR.invitePeople(); Presenter presenter = new Presenter(“Jonas Auken”); presenter.prepareSlides(); presenter.createExampleCode(); while (!done) { try { done = presenter.performPresentation(people); } catch (QuestionRaisedException e) { presenter.answerQuestion(); } } assertEquals(0.75, people.getRateInspiredToDoTDD);} 5
  • 6. Test driven development• Why? • Feedback loop • Change alarm • Help in bug finding • A better design • Adding functionality by the slice• How and when? • Write the test first • Mock all external objects • Only test worker objects, not value objects 6
  • 7. Good design• “Pretty much what you’d have expected”• No superfluous code• Easy to understand - easy to maintain• Small classes, small methods• Separation of concern - do one thing only• Single layer of abstraction 7
  • 8. Test driven design• The natural next step• Avoid big design up front (BDUF)• Design by refactoring • Design what you need • Mock the rest • Small steps or large steps 8
  • 9. “Find my Ride”• A larger example• Web application• A few complex issues• Java6, JSF 2, Tomcat server, mock database 9
  • 10. This is not real• No users telling us what they want• No component and backend design• No planning• So, this is not really agile - it’s just an example of TDD 10
  • 11. Immediate feedback• The red-green cycle• Test, code and refactor• Feedback in every cycle• Short cycle or long cycle 11
  • 12. Comfortable refactoring• Refactoring in every cycle• Avoid the “big refactoring in the sky”• Refactor when the test is green 12
  • 13. Towards a better design• Walking skeleton• One slice of functionality• Hardest thing first• Knowledge is gathered• Choices can be deferred• Better estimates and better design 13
  • 14. How do we get started?• Inspiration?• Discussion?• Questions?• Remarks?• Personal experiences? 14
  • 15. Books & Links• Growing Object-Oriented Software Guided by Tests - Steve Freeman & Nat Pryce• Test Driven Development: By Example - Kent Beck• Extreme Programming Explained: Embrace Change - Kent Beck• Clean Code - Robert C Martin• Refactoring: Improving the Design of Existing Code - Martin Fowler• 10 Ways to Improve Your Code - your-code-neal-ford - Neal Ford• SLAP - abstraction-principle - Mark Needham• Do One Thing - you-drop - Robert C Martin• Test Driven Development - - Wikipedia• Tech & Talk - - Jonas Auken 15