Sustainable Test-Driven Development
Motivation
The practice of Agile Software Development requires, among other things, a high degree of flexibility in the coding process. As we get feedback from clients, stakeholders, and end users, we want to be able to evolve our design and functionality to meet their needs and expectations.This implies an incremental process, with frequent (almost constant) change to the code we're working on. Each change is an opportunity to make the product more appropriate to the needs it is intended to address.
Traditionally, changing working code is a stressful prospect, one which we have tended to shy away from. We have embraced entire development paradigms, such as the waterfall process and SDLC, in an attempt to minimize the need to make changes, in the hope that enough up-front preparation will mean we get it right in the first place.
Most of us have found this to be a failed dream. No matter how hard we try, we're almost always faced with making changes. Because of this, many developers have decided to embrace change as their primary working mode.
However, the reasons we feared change in the first place have not disappeared. Therefore, we need new tools and techniques to ameliorate the problems that change creates.
Refactoring, the discipline of changing code without harming it, is one such technique. Unit testing, which ensures that a given change has not caused an unforeseen ripple effect in the system, is another.
What you learn
Students learn to use an XUnit testing framework (Junit or NUnit or CxxTest), learn a variety of refactoring techniques, with hands-on exercises to solidify this knowledge.Finally, the practice of Test-Driven Development, which utilizes Refactoring and Unit Testing in a particularly fine-grained way, is demonstrated. A hands-on TDD project will dominate the third day.
Course Length
3 daysCourse Level
IntermediateCourse Outline
Day 1: Techniques
- A brief overview of the motivations behind Agility, and TDD specifically
- As a group, we all get the testing framework up and running on all needed machines.
- Review Code Qualities, and how they relate to Testing and Testability
- Unit-testing in general, leading to the benefits of TDD
- A small Unit-testing/TDD exercise
Day 2: Design
- Mock Objects, with an exercise
- Code Smells, and Refactoring
- Refactorong to the open-closed, just in time design
- Legacy code refactoring exercise and debrief
Day 3: Reality
- TDD and Design, revisiting the exercise from Day 1
- TDD and Design, putting it all together. This includes a larger hands-on lab project.
Who is this course for
Software developers who want to learn how to code better and learn new design techniques.Equipment
A laptop or desktop computer with XUnit installed and an IDE with which they are comfortable working is needed for every pair of participants.
Prerequisites
Participants should have a solid background in an object-oriented language such as Java, C#, or C++. They should have at least minimal proficiency with the language of the course, which is usually Java or C#. (The course can perhaps be given in another language or combination by prior arrangement.)- Anyone weak in object-orientation should read Part I's "An Introduction to Object-Oriented Software Development"
Chapter 1 "The Object-Oriented Paradigm" from Design Patterns Explained: A New Perspective on Object-Oriented Design (Second Edition)
- Anyone who doesn't know the UML should read Chapter 2
"The UML—The Unified Modeling Language" from
Design Patterns Explained: A New Perspective on Object-Oriented Design (Second Edition)