Live data from Hacker News

Poll: Do you test your code?

news.ycombinator.com

321–330 of 351 posts

Re: Poll: Do you test your code?

#321

Earlier quoted context omitted.

The mistake here is that what you're describing is a functional test, not a unit test. A unit test for a piece of code like this might be "Given that the time signature for the music is 3:4, the software puts 3:4 in the appropriate place on each line of output". You then might write a variety of cases testing that it deals correctly with (say) a changing time signature at some point in the piece. The upside of this i…

Who said anything about unit tests? But okay, is it really so much easier to write a test which just tests changing the time signature? It's still going to require doing OCR. And if I'm really testing it, I've got to make sure the time signature change comes at the correct point, which requires OCR on the notes around it. Also the bar lines (to makes sure the time signature change is reflected in the notes per bar an…

PS Now have unit tests that the ABC parser can parse time signature changes.

Re: Poll: Do you test your code?

#322
post #204

Earlier quoted context omitted.

A framework previously designed to work on a single device was ripped apart and several key elements were made to run over a network remotely instead. (That may sound trivial in a sentence, but if anyone ever asks you to do this, you should be very concerned.) The framework was never designed to do this (in fact I dignify it with the term "framework"), and tight coupling and global variables were used throughout. Thi…

So, at the end of the day, you never actually did design-from-scratch work, and instead used tests to verify incremental design improvements (key part: verify not create )?

The sum total of the improvements were not incremental. Testing helped give me a more incremental path, but from the outside you would not have perceived them as such.

Re: Poll: Do you test your code?

#325
Not only does testing help with managing large codebases by being able to make actual assertions about certain parts of the code (to be able to prove correctness) but it also improves the quality of your code. If you're writing code that must pass certain tests, you inherently start to think about making that code more modular and de-coupled, ie injecting dependencies rather than creating them for a start.

Re: Poll: Do you test your code?

#326
post #152

I answered "a few critical things" ... but, for the most part, testing is tedious, frustrating, and a time-sink for me. I recently paid someone $100+ an hour for some remote TDD coaching. It's helping a bit but hasn't really change my attitude towards testing (yet). What bugs me: - Testing frameworks and "best practices" change way faster than language frameworks and I simply can't keep up. What rspec version do I us…

Look at it this way: you must be testing code as you write it anyway. There's really no other sane way to do it. You make a change, you load the page and see that your change worked, or you call your new function from an interactive interpreter. Smart automated testing just takes all that extra test work you're already doing and saves it as you go along. No need to try to invent extra things to test. You just test wh…

Smart automated testing sounds amazing, until you realize that it's not smart at all. The dumb computer that you're ordering to do your bidding is the same dumb computer that is going to be running your tests, and chances are the programmer is invariant as well. In short, good programmers need unit tests less and bad programmers will write bad tests. You can't fix a personnel problem with technology.

Re: Poll: Do you test your code?

#327

Earlier quoted context omitted.

Not groking TDD, I literally worked my way thru the book, doing each and every step, just to get the gist of the experience. TDD works fucking great. If you know what you're doing. Alas, that's a big IF. Most of the stuff I do, I'm just figuring shit out. Mostly, like when designing a new library, I work outside-in. I imagine how I'd want to do something, writing the client pseudocodeish stuff first, and then trying…

what book?

Test Driven Development by Kent Beck

http://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/0...

Re: Poll: Do you test your code?

#328

Why is there no "and also click" option for, "we are unhappy with the amount of testing we do, and are gradually adding more".

Really, downvoted? The survey seems predisposed to result in the conclusion that testing is a waste of time.

My company finds it worthwhile enough that we are never happy with what we have. We could always write better tests, but we need more engineers than we can find to hire. So we are unhappy with the current situation, but are working to improve.

Post reply on HN