Refactoring is the black beast of development. Most of the times, as developers, we go through the state “refactoring” but… What is refactoring? What is the best way to improve our code? and what does it mean to improve our code? To answer those questions we’re going to code again together in the next TDD MeetUp in Ho Chi Minh City, Vietnam.
THE IMPORTANCE OF TDD
As we saw in our last TDD MeetUp in Saigon, TDD is an important tool for software design. I’ve written a lot about TDD and how difficult it can be to integrate that methodology into the software team. I am actually very comfortable with that methodology, and all our code team uses TDD and yes, we are fast and almost have no bugs!
When we talk about refactoring, TDD also becomes a very good strategy to deal with bugs and to solve them. But you still need some tools, or let’s say patterns, to know how to refactor.
So when you refactor you don’t “change”. Actually, you’re extracting a class, implementing an interface, extracting a method, applying humble objects, etc.
Using TDD to solve bugs means that the bug is a broken spec, so my job is to put that spec in green.
THE GILDED ROSE REFACTORING KATA
To “learn by doing”, we’re going to do a kata together, the gilded rose is a nice piece of code to work with. My proposal is that I would do the kata on my laptop and screen it, going step by step and commenting every decision. Let’s see what’s the best approach in every case and specially, let’s do it with TDD!
There are plenty samples of that kata on youtube. Some the coders who did it are honestly really cracks. Take a look and enjoy.
WHAT IS IMPORTANT TO KNOW IN ADVANCE
As I said, no laptops needed this time. Just a notebook and a pen to write down what you think is interesting. You will understand why it is so important to master your IDE, why it is so important to know about shortcuts and design patterns.