Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 14, 2022 02:36 pm GMT

TDD x Coding Challenges

I hate coding challenges. And with that out the way...

I mean, I understand what they bring to the table, depending on where you work its definitely a way to train. But most of the time, its either a chore you need to learn and train to do or a fun brain teaser you do in your free time.

But someway, somehow for reasons unknown to me... its something many hate and yet is the industry standard... want a job in tech?
Use this terrible online (and not your) IDE everyone will hate to answer the cumulative weight of a watermelon person problem that has 10 million watermelons where its size changes in a Fibonacci pattern.

My challenge (pun intended)

What I wanted: Can you use, explicitly, TDD to solve coding challenges?

What I found: depends. (the default programmer response)

While you can (and should) use TDD even without using TDD.
(basically, you go through the red-green-refactor cycle, just without writing tests.)

Why TDD might not the right tool for the job:

  • You can end up wasting time (especially when its a timed challenge) on things that are not important to the test at hand.
    • many challenges say that the input doesnt need to be validated
    • you already know the minimum/maximum values possible
  • You already have test cases.
    • you might not know what they are (and some platforms even hide if youre passing everything or not... not sure why...) so, do you even need to actually write the tests?
  • Many challenges are self-contained.
    • most of what you have to make could be made in a line and not in multiple functions/classes.
    • if you start with a wrong abstraction or data structure, all the buildup youve made goes to the trash.

Is it useless then?

Im not saying youre not gonna get a solution using TDD, you will.

Most likely, when youre totally lost, TDD will help you reach a solution...

It just might not be the BEST solution, the solution that will pass all tests (especially the time/space complexity ones).

Now with you!

What is your experience with coding challenges?

Do you have an alternative for solving them?

So far, the best advice I got and that I can give you is the one youll probably see in many games out there (with pun intended): git gud.

Cover Photo by Jukan Tateisi on Unsplash

buy me a coffee


Original Link: https://dev.to/noriller/tdd-x-coding-challenges-5cce

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To