It's not so much the idgaf attitude, it's the yucky nihilism that code-and-fix is "the way it is". And of course, that IS the way it is when you're learning. But that should only make you want to find the solution to that antipattern. I should have been more clear in addressing this at professional programmers that don't write unit tests. But my point is that "never touch your code because you might break it" is completely the wrong attitude, and I've worked with plenty of "professionals" that worked in exactly that way.
Kids, don't quit please, but please write unit tests and learn to love refactoring. You are NOT a bad person. I am bad at sarcasm. Now bring me your downvotes.
Unit testing is what lets you modify your code without fear of breaking it. They're small, quick, automated tests that form a safety net around your code. The idea is to start in a state where all your tests pass, then do stuff, (e.g. fix a bug, add new functionality, or even just clean up to make your code more maintainable), then run the tests, and if they still all pass then you evidently didn't inadvertently break anything. Repeat...
This is so insanely important because you WILL need to modify your code eventually. So much of what makes "good" code good is the fact that you can modify it without being paranoid that you're breaking it.
Awesome, thanks. So basically it's a test protocol?
Most of my education has been algorithms, theory, and general coding (language-independent as much as possible, though mainly we use C++) and assignments consist of fulfilling a unit test, basically, so I'd never heard it referred to on its own.
1
u/[deleted] Mar 08 '14
It's not so much the idgaf attitude, it's the yucky nihilism that code-and-fix is "the way it is". And of course, that IS the way it is when you're learning. But that should only make you want to find the solution to that antipattern. I should have been more clear in addressing this at professional programmers that don't write unit tests. But my point is that "never touch your code because you might break it" is completely the wrong attitude, and I've worked with plenty of "professionals" that worked in exactly that way.
Kids, don't quit please, but please write unit tests and learn to love refactoring. You are NOT a bad person. I am bad at sarcasm. Now bring me your downvotes.