⬆️ ⬇️

Making TDD a habit: problems and implementation

image From the translator. On Habré quite a lot of articles on TDD. But unfortunately they do not have detailed information on how to implement TDD in a complex, at the company level. It seemed to me that this article provides an answer to this, and if you set such a goal, then this article may be useful to you.



I ran into teams in our organization that are trying to implement Test Driven Development (TDD). Sometimes one or two developers manage to use it without help, but for most of them this does not work. To better understand the problem, I conducted a survey among team members and found that even after training there is still a lot to be done. This strategy was designed to help anyone implement TDD in an organization, although some of the ideas apply only to medium and large companies.



My research of team members (all of them were trained) showed the following problems:





Main problems


Based on these symptoms, what are the main problems?

')

Test driven development is hard to learn. The training phase (the time during which it becomes a deep-rooted habit) usually lasts from two to four months, during which performance decreases. Ultimately, the benefits will be obvious and TDD will be used on its own, but the question is how to make this time appear? Many developers give up after a few days.



Most implementation strategies that I have seen focus on classroom instruction (or e-learning) and one-on-one mentoring. Well done, they certainly reach their goal, but I think it takes much more.



Classroom training suffers from two key problems: the examples are too simple and not associated with real problems, and there is almost no chance to try this in practice.



Interactive learning has an advantage, allowing you to dive deep into the topic. However, there are still not enough chances to try all this in practice. In addition, these courses usually take place without interaction with other students. Hearing questions from your classmates and colleagues, you can often reach an understanding yourself.



Mentoring one-to-one does not scale, except for working with several members of one team at the same time. This is especially difficult in a large corporate environment where there are only a few experts and hundreds or thousands of people who need help.



Books are an excellent option, but few developers like to read books on engineering practices, and even those who study TDD in this way face great challenges. Like online courses, the problem of learning lies on their own shoulders.



And finally: inherited code makes an already difficult task hundreds of times more difficult. Developers rightly ask the question: “How can I test these closely related objects? This code is complicated, how can I test this algorithm? „



One approach


What can work? Previous approaches suffer from two key problems: lack of depth and communication. The complete strategy contains a combination of approaches.





At the heart of this plan lies the creation of permanent communication and the expansion of cooperation around TDD. Three of these strategies focus on this area: pair programming, Coding Dojo, and reading seminars.



Coding dojo


Coding Dojo (using the Randori format) is an event where a small group of people (no more than 15) solves problems using TDD (adapted from Danilo Sato ):





From experience, I recommend that you choose very small tasks to start.



Reading seminars


There are a number of books for reading seminars:





Usually teams process 1-2 chapters per session. The pace is slow enough for people to read outside of work. In addition, it gives enough time for in-depth discussion of several points from this chapter.



Benefits of collaborative learning


Seminars should have pizza (or any other food) - as you ask people to spend their personal time doing something like work, they need an incentive. The two workshops can alternate, so that people do not feel that they are stuck in one thing. And we should not expect that the group will be constant from meeting to meeting.



Seminars and communities are much more useful than self-study, because group members communicate and benefit each other. As a result, we will learn about things that we ourselves would never have reached.



Making TDD a habit


In general, here are the keys that. It seems to me that they help create a successful implementation strategy:



Source: https://habr.com/ru/post/157729/



All Articles