šŸ“œ ā¬†ļø ā¬‡ļø

TDD pragmatism

So, my last entry: a start-up trap has caused a lot of noise. Among the people expressing agreement and support, there was also a group of people who categorically disagreed. I will not summarize all the differences here, because this month I have already exhausted my limit of abusive words. But I got into one alternative opinion and consider it necessary to discuss it.
It's about the old conflict "pragmatism against dogmatism." The dissatisfaction was mainly in the fact that I proved myself too dogmatic. An alternative view is that in some cases the use of TDD may be justified, while in others TDD may result in too high costs. So you must be a pragmatist and make choices wisely.
At first glance, this idea sounds completely justified. After all, pragmatism is good, isn't it? Suppose you knew in advance that, using TDD, you did not meet the deadline, and that if you didn’t apply, you would have done it, you wouldn’t use TDD, right?
Right. No questions. And, indeed, sometimes it happens that such a path is correct. The purpose of this post is to clarify when, in my opinion, the use of TDD may be too costly.
But before I begin, I would like to make a point. TDD is a discipline for programmers, such as double-entry bookkeeping for accountants, or a procedure for sterilizing instruments for surgeons. Are there times when accountants do not use the double entry method? Are there cases when surgeons do not sterilize instruments?
The answer is yes, in both cases. I even doubt that accountants use the double entry method when they balance their personal checkbooks, or when reconciling the total amount of a bill in a restaurant. I could be found wrong about the first statement, after all, I myself have used the double-entry method for years to balance my checkbook. But I gradually realized that the effort expended did not cover the possible risks. As for the last example, I think everyone will agree that to check the bill in a restaurant, the double entry method is an obvious brute force.
Now as for the surgeons and the sterilization procedure: a couple of years ago I had a lipoma removed from my leg. My wife watched this procedure. The operation was performed under local anesthesia in the doctor’s office. I heard that my wife asked the doctor why he hadn’t performed the sterilization procedure in preparation for the operation. He replied that for such a simple operation, a ā€œcleaning procedureā€ is sufficient. My wife and I were satisfied with this answer, and the doctor performed the operation.
After a couple of days, the incision became inflamed and began to hurt. An infection got into one of the stitches and the doctors had to re-make the incision and clean everything there. I don’t know if the cleaning procedure ’was the cause, but since then I have insisted that the doctor in charge of me performed the sterilization procedure, and not the cleaning procedure’.
However, the statement remains true. There are cases when TDD is too expensive and should be applied more light discipline. I hope that my story has convinced you that such cases are extremely rare and that the meme of pragmatism should not interfere with the application of your disciplines simply because they seem to be inappropriate.

Pragmatism.

So, when do I not apply TDD?



')




All this is not a dogma.

This list is not complete. I’m sure that I’ll think another time about why I sometimes don’t write tests, but the essence of the above list should be clear. Pragmatism takes effect when you practice TDD, it's not all dogma.
However, I respect dogma. There is a reason for this. Pragmatism sometimes gains the upper hand, but I will not write any significant part of the production code without applying all possible efforts to apply TDD.

From the translator: Mark Seaman has already read this article from Uncle Bob and has reacted with his own , in which he disagrees with some points and dwells on them in a little more detail. There will be time - I will try to translate.

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


All Articles