My name is David Tanzer and I have been working as an independent consultant in the software industry since 2006. I help my clients to write better software (higher quality, better architecture, better design) and to get better at writing software (better processes, better communications, less friction and waste).
One of the first things you must learn when starting with test driven development - or TDD - is how to write a good, “red” test and how to make this test green.
And this is already harder than you might think.
A good red test constrains the implementation you are about to write in just the right way - not too little and not too much. It takes you one step closer to your overall design goal; that might still be pretty far away. It enables you to write an implementation that will allow you to make the next test red again.
To make the test green, you must write the smallest possible implementation that will pass the test. And most people I know were surprised - schocked! - how small is sometimes necessary.
Let’s talk about refactoring again: How can you move some code to different value objects using small, safe steps? In this video, I want to show you exactly which refactoring steps I take to extract a factory method, move it to one value object and move some code around it to another value object.
In my last video about “Refactoring Primitive Obsession”, I did all that very quickly to give you an overview about the whole process. I have added a link to that video in the description.
Today I want to show you a small step from this process and explain exactly what I did.
I sometimes teach test-driven development, or TDD, to developers who have never done it before. And at the beginning of those trainings, most of them struggle a lot with the first two steps of the “Red, Green, Refactor” cycle: How to write a failing test correctly and how to make this test pass correctly.
In this series of blog posts and videos, I want to focus on those first two steps: “Red” and “Green”. You can find all the parts of the series here: