DEV Community

UponTheSky
UponTheSky

Posted on

[Book Review]Test-Driven Development by Kent Beck

Background

Just having begun my job in a small startup, I was in need of catching up on the product code and managing a part of the team. So I was really impressed by the message from uncle Bob's Clean Agile book. From this book, Uncle bob pointed out the technical part of Agile: TDD & Refactoring.

Yes, testing is really important. I deeply felt it when I was working for my previous company. At that time, I was merely using TypeScript and no framework. Design pattern, architecture - they were all up to me. Although I know nothing about them, I was definitely concerned about one thing - the quality of the code. And that quality comes from a bunch of the tests.

From those experiences, I was eager to learn about TDD, and I happened to discover there was this book in my Univ.'s library. But this book was not like reading uncle Bob's books - You have to type in your code while reading the book aside. So I picked one of my favorite languages - Python - to read the book. It took almost a month(25 days, maybe) to finish this book.

My summary of this book(with my Python code) is in my Github repo: https://github.com/UponTheSky/read-tdd

So is it worth reading?

Well, My first impression was, that the book was a bit hard to understand. Sometimes the logic went in the way that I didn't expect(Why do we need that type in Java?). Also, some messages were a bit confusing and seemingly not coherent in that context.

However, this book is intended not to teach you any theory, but a practice of TDD. In that sense, I would definitely say it is worth reading(If you are a Java or Ruby programmer, then I would recommend more since a large portion of this book is for OOP and its design).

The book starts from making actual tests, and the author implements the code as if he knows nothing about the code, and he is one of us - except he is an expert in TDD. So it was like following a tutorial in a YouTube video. The messages were like from a friend or an older brother who teaches you how to code. From nothing but a todo list, he builds up the code and tests simultaneously.

Best part?

My favorite part was Part 2. It was actually a tutorial on building a unit testing framework in Python. But more than a tutorial. I learned how to build a program from scratch, how a test should behave, and many others. Although it is written in Python(probably Python2. Sorry, I don't know Python2), you could do exactly the same in other languages like Java or C++.

Worst Part?

There weren't any bad parts, except some confusing comments from the author. But if I had to choose one, I would say it is Part 3. This part is a collection of principles of how TDD should be conducted. It was a good review of the previous two parts, but I thought those messages were like from the Bible: you know what the author means if you are a programmer. So I think this part could have been much better if the messages were a bit more concise.

And some of the messages were like from his real-life experiences. It was good to hear from someone how one works or behaves when one hits a problem, but I felt that the description was not concrete, so it was not that easy to understand what he means as much as uncle Bob.

Conclusion

I cannot say it is kind of 'must-read'. You could find a bunch of tutorials on Youtube about TDD, and there are texts in various languages on TDD. I would hardly recommend it if you're a beginner at all. But it is a classic, which means one can get valuable messages from reading it. It was a good practice, and I feel more confident about writing my code than before, after reading this book.

Discussion (0)