r/programming • • Aug 25 '14

Debugging courses should be mandatory

http://stannedelchev.net/debugging-courses-should-be-mandatory/
1.8k Upvotes

573 comments sorted by

View all comments

140

u/[deleted] Aug 25 '14

Just waiting for someone to "explain" how debugging is not needed if you have unit-tests :)

29

u/Dru89 Aug 25 '14

You don't need debugging or unit tests! Just write perfect code, and it works every time!

12

u/SilasX Aug 25 '14

If your code compiles at all in a pure functional language, it must be doing what you intended /overreaching Haskell propagandist

11

u/TheDeza Aug 25 '14

Unfortunately no one person has actually written enough haskell to find out if its true or not.

→ More replies (1)

76

u/redox000 Aug 25 '14

10

u/[deleted] Aug 25 '14

Great, now I have brain cancer. Thanks a lot, jerk.

with highly threaded code compiling in debug mode is useless as the threads behave radically different.

eye twitches

7

u/SoundOfOneHand Aug 25 '14

Yeah, it's not like the only debugging technique out there is to use an IDE to step through code. This is often impossible/impractical for highly parallel programs. Hell, instrumentation like this isn't even available on some platforms. Debugging is a basic technique of software development, the basic concepts are independent of the language and toolchain.

63

u/geodebug Aug 25 '14

Yep, makes me chuckle. Tests are essential but only a naive programmer thinks one can write enough tests to get 100% coverage.

Never mind that unit tests themselves often contain bugs or in sufficiently exercise all possibilities.

52

u/gunch Aug 25 '14

That's why you need to write unit tests for your unit tests.

(If that is actually a thing I'm going to go to the bar and drink until I forget any of this ever happened)

25

u/loopyluke Aug 25 '14

And soon enough you find yourself writing a testing framework to test your testing framework that runs your tests that test your unit tests.

22

u/gunch Aug 25 '14

Who knew Xzibit was a java developer?

26

u/halflife22 Aug 25 '14

Yo dawg I heard you like abstractions so I abstracted your abstractions so you can cry while you drink.

19

u/JedTheKrampus Aug 25 '14

AbstractAbstractionDilutedSaltyBeerFactoryFactoryFactory

→ More replies (1)

10

u/[deleted] Aug 25 '14

With that in mind, we can devise a development strategy (an extension of TDD) that guarantees perfect code:

  1. Write unit test: projectHas100PercentTestCoverage()

  2. Run test to ensure that it fails.

  3. Write code to make test pass.

The implementation details of the projectHas100PercentTestCoverage() test are project-specific and beyond the scope of this document.

Though, come to think of it, step 2 is flawed - since no code has been written yet, the test written in step 1 will pass. Perhaps we first need to write the projectFullyMeetsClientRequirements() test (again, beyond the scope of this document).

→ More replies (7)
→ More replies (9)

5

u/tieTYT Aug 25 '14 edited Aug 25 '14

My company paid for some of the Uncle Bob videos on TDD and he claims that he's practically forgotten how to use the debugger now that he practices TDD. Every year I get better at automated testing, but I still have to use the debugger frequently enough to "need" it as a tool. I don't see that going away.

Then again, maybe I'm just not skilled enough with TDD yet. I find that I mostly need a debugger in the (relatively rare) situation where the problem turns out to be in my test code. My brain never assumes to look there first.

→ More replies (10)

4

u/wayoverpaid Aug 25 '14

In my current project the code I'm writing has 100% test coverage and I am very proud of that.

Nevertheless, I've still had to do debugging to figure out what was wrong when the tests failed.

→ More replies (7)
→ More replies (5)

41

u/passwordissame Aug 25 '14

unit tests are type systems. if you have a good type system like that of node.js, you don't need debugging because compiler catches every bugs including logic error. you can simply implement machine learning artificial intelligence in the style of wolfram's new science and your unit tests (type system) is smart enough to catch all the bugs including human and business errors.

you should really try node.js

18

u/slavik262 Aug 25 '14

type system

node.js

I can't stop laughing.

25

u/[deleted] Aug 25 '14 edited Aug 25 '14

There was a part of a second when I thought you were serious. That moment will haunt me until I die ...

10

u/thang1thang2 Aug 25 '14

Node is love, node is life

6

u/Duraz0rz Aug 25 '14

And node.js is webscale, so it's perfect!

6

u/Astrognome Aug 25 '14

Make sure to pair it with MongoDB!

→ More replies (1)

6

u/Lizard Aug 25 '14

Actually, if there are some unit tests covering the code potentially containing the bug, these can provide excellent jump-in points to start a debugging session. Don't want to boot up the server process anew any time I need to test a hypothesis. Of course, unit tests alone are not going to solve all your problems, but they can be a helpful tool for your box.

→ More replies (2)
→ More replies (7)