Re:When To Write Bad Code
by brandonsavage on Tuesday January 29, 2013 @11:19AM
(#5134752)
The person I was mentoring (that prompted this blog post) was having trouble getting ANY code down on the screen. Being able to write SOMETHING was the hurdle for this developer to overcome.
In most cases though, I agree with you.
I write bad code all the time, I'm writing terrible code right now. I check in good code.
Some people can visualize an entire program in their head and how it will interact. Not me. I hack at the core of the problem I'm trying to solve, until I've solved it. Then I reorganize the code into something that (hopefully) isn't crap. It seems inefficient, but it works for me.
I disagree that writing "shit code that still works" and TDD have to be mutually exclusive. In fact, if I'm going to go the "just get it done" route, I will almost (but not always) try to set up a few tests for it.
Because nothing sucks harder then going back to crap code and trying to decipher what it's doing. If it's crap code, then it's likely non-orthogonal code, which means changing it will likely break something...etc. etc. Tests help me do the refactoring later.
And, also, how do I know that my shit-code-just-works actually works? Sometimes, it's helpful to write a kind-of-shitty-test to at least verify that it kind of works, if not perfectly.