News for hackers. Stuff that matters.
Re:Ask HN: What's the largest amount of bad code you have ev... by iopq on Saturday November 17, 2018 @05:44AM (#18474922)
The code that determines truths about the data never had to be rewritten.

Like, are the two points neighbors? I mean, I'm not going to write a version of this function for a spherical board in the future. Nobody plays on a spherical board.

It's also a really boring unit test. Yes, (1,1) and (1,2) are neighbors. Do I really need to test this function until the end of time?

Re:Ask HN: What's the largest amount of bad code you have ev... by lojack on Tuesday November 20, 2018 @09:49PM (#18499826)
Thats exactly the type of code that should be unit tested. The unit tests are trivially easy to write, and a very naive solution is easy to code up. The tests should take up a negligible overhead in your overall test suite runtime. Then when it comes time to optimize the code because its becoming a bottleneck you can be confident that the more obscure solution is correct.