IBM

TDD Isn’t Hard, It’s Something Else…

TDD Isn’t Hard, It’s Something Else…

#TDD #Isnt #Hard #Else..

“Continuous Delivery”

Test Driven Development divides opinion, but there are few other practices that in real-world development teams reduce bug counts by between 40 and 90%. Software development is a difficult endeavour and so we should take every advantage that we can get, so what is the evidence that TDD works in…

source

 

To see the full content, share this page by clicking one of the buttons below

Related Articles

29 Comments

  1. No Dave ! Not you ! Not this "study" ! They were NOT doing TDD ! That's why it was soooooo hard for them and longer. I quote the study :

    IBM : "With the TDD group, test cases were developed mostly upfront as a means of reducing ambiguity and to validate the requirements, which for this team was a full detail standard specification. UML class and sequence diagrams were used to develop an initial design. This design activity was interspersed with the up-front unit test creations for developed classes. Complete unit testing was enforced—primarily via reminders and encouragements. We define complete testing as ensuring that the public interfaces and semantics of each method (the behavior of the method as defined by the specification) were tested utilizing the JUnit2 unit-testing framework. For each public class, there was an associated public test class; for each public method in the class there was an associated public test method in the corresponding unit test class. The target goal was to cover at least 80% of the developed classes by automated unit testing."

    Microsoft : "The TDD team at Microsoft did most of their development using a hybrid version of TDD. By hybrid we mean that these projects as with almost all projects at Microsoft had detailed requirements documents written. These detailed requirements documents drove the test and development effort. There were also design meetings and review sessions. This explains our reason to call this a hybrid-TDD approach, as agile teams typically do not have design review meetings"

  2. I LOVE TDD. It is the only way to write professional software.
    There is one situation in which it shouldn't be used: when exploring a solution space. But as soon as the design starts to solidify, the paradigm should shift to TDD.

  3. We programmers are never required to provide a warranty against future defects found in our Production code. Nor are we rewarded for writing Clean and maintainable (same thing really) code, but for meeting deadlines so we can go onto the next project. And also for learning the latest frameworks and libraries and tools, to polish our resumes for our next job. That adds up to a lot of distractions. So, here is the proposition I put to you, fellow professionals: "Do you take pride in your work?"

    In the past 7 years I have worked with a couple of hundred Java programmers all over the world. Only two of them wrote automated tests unless management forced them to – after the fact – to get 80% code coverage. My code reviews with junior and medium programmers rarely had an effect on code quality beyond the Pull Request Classes. But in a few cases the programmer started writing code that they were proud of. However, TDD is still a long way off.
    Dave's audience doubtless includes a lot of proud professionals. We have a lot more work to do.

  4. Imo the Microsoft/IBM study doesn't tell us anything about anything. It's from 20 years ago, Dave said waterfall was used, the abstract called agile a methodology (it couldn't be more ignorant than that) and it appears that the programs were toy programs and typically several tests were written at once.
    To begin with I don't see how anyone could take TDD seriously except as a small but essential component in the context of DORA's research findings (as shown by Dave in the video), and for Production software development (except in the case of Katas).

    To do TDD, you have to write Clean code or you won't be able to write one test at a time, first. You also need to be an expert software architect/designer and do DDD, because you have work to do up front, and as you go along – being agile doesn't mean you make it up as you go along.

  5. Write the tests in the implementation language. If you can't do that, use another language, or admit you're doing some BDD/TDD hybrid (in Dave's example).

    One of the issues for TDD is that the languages we commonly use were not designed for it, so it is easier to code without doing TDD.

  6. The lack of nuance is at staggering. It always is a matter of "It depends".
    Dave argues that "if I don't know what the code should be doing, I should think about it more"… However, I "think about it" by "writing code" and see where it leads me. When both the problem space and solution space is well defined (as with the Waterfall teams) or that "new feature is on table", then TDD works great. When you are exploring what is possible (or not), to determine overall structure, to get a feel for how to approach the problem space, or even how and if a particular technology/library should be used/integrated or not, then TDD is just a hindrance. TDD (as defined by Uncle Bob) is not a panacea, but another tool. More important, and less spoken about is what I call "Design for Test" mindset, which is something I learned/borrowed from electronics industry. And no, "mocks" is not a silver bullet there either… Gosh, I hate the absolutism in this industry.

    I am more elaborate in this old comment; https://medium.com/@niclas.hedhman/tdd-is-dumb-totally-agree-9581a6c76b2a

  7. I like that TDD forces you to think first about good APIs and contracts. Also about how responsibility is divided between parts of the code. But once you can do that on your own, you can ignore the rest of TDD.

  8. Great video to watch while I'm using TDD and while it is paying dividends. I'm reverse engineering some software for which i don't have the source. The original software can export it's config as a text file. Using TDD i was able to find bugs in my code but also find bugs in the original authors code. I was working with a binary file and offsets of the data change depending on the type of record. TDD made it easy to get that right. I discovered i made a spelling mistake deep into the build. It turned out to be all over the code and tests. TDD allowed me to correct this and ensure i didn't break existing code. The hardest part has been ensuring that i have the discipline to stay the course. Thanks for the leadership on TDD. 16:03

  9. I think one common barrier to TDD is actually to setup the testing. Application starts with system.out.printlin("hello world"), and testing for side effects may be not nearly obvious . Okay hello world is not our business case, but what if i want to test logging, which may be part of the business requirement as security audit relevant stuff? You have to hope that someone has already done that, and there is an instruction somewhere on how to do it correctly. With correctly, i mean writing such tests may require above average understanding of the underlying technology. Not every average java backend developer has ever touched any logback.xml file. This forces you to lift up your understanding of your programming environment. And that is where abstractions get ugly. How many java developers know how JVM works? And how many know how to test that, what others tell them about how JVM works is true. Our tech stacks became so opaque, that even when you write unit tests you may not really know what you are doing exactly. I think proper unit-testing has much seeper learning curve as our convinient testing tools suggest.

    I once was writing a command line analyzing utility for AD printouts, and my fist quest was to find a CLI library which brings testing capabilities to the table. So that i could effectively test for command line inputs. And there were only few of them. If you are not lucky to work with "unit-test enabled" libraries or frameworks, the whole TDD approach may turn out into a challenge of fiddling around and getting the wirings for the TDD right, instead of focusing on the actual user value of the application. This would make it difficult to advocate for TDD.
    For me this is a core challenge, not knowing how to do it correctly (testing the right thing) for non-mainstream situations.

  10. The moment you get into agile like arguments (you are doing scrum wrong etc) you know that something is off. The ugly reality of software (like everything) is that success is not about the processes, tools methodologies but the people their experience and competence. It's no wonder why on every project it's that small team of great people that make it happen, yet none admits it since it's admitting the failure of management. Competent people can use any tool and process and make it work to their benefit. Software should move, from headcount and the fallacy of cookie cutter process to competence.

  11. Software development today includes provisioning cloud resources with terraform or some other IAC software. How would you TDD cloud infrastructure, for example a simple real-time data pipeline with kinesis, lambda, and SQS?

    Or is TDD irrelevant for provisioning cloud resources?

  12. Not a fan of TDD at all but I have seen so much quick n dirty BS… that moi has to take over that just about any paradigm is better than this unenlightend imperative crappy nonsense.

    Lets use Pydantic to create types more complex than some unix cli tools and process them in methods with over a 1000 lines of if else trees in a class that has no conceptual basis with names that are clearly verbs…

    How do people still write this much crap in convenience languages like Python??!! Smart tools apparently enable dumb practices and horrible businesses.

  13. It's not hard to do, it's hard to contextualize. I recently started a small vending machine project, and it involves code. I put that code on Github – does this code need to be done with TDD? Given that you are supposed to start with TDD, why would a small python project I built specifically as something to build with my kids need TDD? How much time do I set aside to try and test hardware – like a coin acceptor's inputs for different sizes coins – for a project that is meant for fun? The code is a small, almost insignificant aspect of the project.

    In other words, a lot of larger projects start from humble beginnings, and they often start in a single script, or CLI that just does something simple. In my experience, most projects don't begin with a thoroughly written requirements document – where beginning with TDD makes obvious sense. I think a lot of this TDD evangelism misses so many examples of cases where TDD from the start would seem pedantic and almost a bit narcissistic.

  14. TDD is not hard if you know it
    Knowing makes everything easy
    Learning is harder for everything
    Programmers always go for the least resistance route
    Therefore programmers always prefer what they already know
    Therefore TDD is hard to learn because learning is hard
    Not because TDD itself is hard

    Most programmers hate when you teach them a new thing
    For them its just another nonsense most likely

    That's partly why this channel keeps making the same video so maybe it can break some more programmers resistance: TDD is not hard

    Kudos for that!

    I don't know if this is the best way, but it's one way to promote something.

  15. I do a lot of 2 day (ish) freelance projects that are little more than WordPress sites with a WooCommerce integration. While I try to write unit, integration, and e2e tests in all my projects with a standardized CICD pipeline, often with clients with budgets less than 15k, I can't justify the cost of writing all these tests. It really slows down my development. And time is of the essence for these projects, the only way I'm profitable is if I complete these within a certain time period.

    Obviously if I'm working on a Next or a Laravel project with a budget of 200k or so, yes, TDD is really nice.

Leave a Reply