Sure coming up with a great algorithm can be fun, but programmers only get true freedom to express themselves in their comments. And it’s always fun when you are fixing a bug and run across a funny or ironic comment that you don’t recall typing but you can tell without a doubt that you were the one that wrote it. While looking through some code I wrote about a year ago, I ran across these comments and thought I’d share.
1 2
//this math is right... work it out if you don't believe me. :) long numSubLists = (numPRC + (MAX_SUBLIST_SIZE - 1))/MAX_SUBLIST_SIZE;
1 2
//this could only be false if something is broken hard... Assert(numReturned == returnSize);
PS: assertions are awesome. I’ve found nothing else to be better at preventing future programmers (especially myself) from breaking my code.