You are viewing a single thread.
View all comments View context
73 points

That supposes to have a clear idea of what you’re going to code. Otherwise, it’s a lot of time wasted to constantly rewrite both the code and tests as you better understand how you’re going to solve the task while trying. I guess it works for very narrowed tasks rather than opened problems.

permalink
report
parent
reply
29 points

100%. TDD is just not practicably applicable to a lot of scenarios and I wish evangelists were clearer on that detail.

permalink
report
parent
reply
19 points

You could replace “TDD” with pretty much any fixed methodology and be completely accurate.

permalink
report
parent
reply
15 points

This is the reason I dislike TDD.

permalink
report
parent
reply
13 points
*

constantly rewrite both the code and tests as you better understand how you’re going to solve the task while trying

The tests should be decoupled from the “how” though. It’s obviously not possible to completely decouple them, but if you’re “constantly” rewriting, something is going wrong.

Brilliant talk on that topic (with slight audio problems): https://www.youtube.com/watch?v=EZ05e7EMOLM

permalink
report
parent
reply
12 points

The only projects I’ve ever found interesting in my career was the stuff where nobody had any idea yet how the problem was going to be handled, and you’re right that starting with tests is not even possible in this scenario (prototyping is what’s really important). Whenever I’ve written yet another text/email/calling/video Skype clone for yet another cable company, it’s possible to start with tests because you already know everything that’s going into it.

permalink
report
parent
reply
4 points

TDD doesn’t imply that you write all the tests first. It just mean you have to write a test before you write a line of production code.

The idea is to ask yourself “what is the first step I need, where am I going to begin?”. You then write a test that validate this first step and fail. Then you write the code to make it pass. Once your done with that, you ask yourself: "what’s the next step? ". You, then, repeat the process for that step.

This is a process you are going to do anyway. Might as well take the time to write some test along with it.

permalink
report
parent
reply
3 points

That leads to focusing on the nitty gritty details first, building a library of thing you think you might need and you forget to think about the whole solution.

If you come up with another solution half way through, you will probably throw away half of the code you already built.

I see TDD as going depth first whereas I prefer to go breadth first. Try out a solution and skip the details (by mocking or assuming things). Once you have settled on the right solution you can fill in the details.

permalink
report
parent
reply
4 points

The tests help you discover what needs to be written, too. Honestly, I can’t imagine starting to write code unless I have at least a rough concept of what to write.

Maybe I’m being judgemental (I don’t mean to be) but what I am trying to say is that, in my experience, writing tests as you code has usually lead to the best outcomes and often the fastest delivery times.

permalink
report
parent
reply
0 points

Everything is made up of narrow tasks, you “just” need to break it down more :)

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 6.9K

    Monthly active users

  • 1.4K

    Posts

  • 32K

    Comments