One of algorithms for the last project (yeah, I said "one of")
Last project taught me an important lesson : If you have a very good algorithm, which you believe can achieve the goal of the project, just stick with it.
Maybe this notion is too trivial to be pondered, but often our implementations ignore this basic principle. We tend to ignore the algorithm especially during testing. If a case failed, then we'd rather change our code specific to the case (adding a if-statement for example). More testings are done, and if the implementation is not good enough, more if-statements are added, which makes the codes difficult to be debugged. Take my word, however, with a grain of salt; handling cases are needed when they are needed. Just keep in mind that overdoing it would hurt you.
Why is it so? I can think of 2 reasons:
1. When we have to handle individual cases with individual solution, there will be possibility that the cases we handled successfully would make other cases fail. And when this happens, we tend to handle the failing cases, and now we have to fix the issue all over again.
2. (This one I mentioned earlier) It will cause bloating chunk of unnecessary codes. These are not easy to debug and even worse, could derail you from the real algorithm.
3. A good algorithm is not idiosyncratic, so we shall put our trust on it. Even better if the algorithm is already proven mathematically.
You know you're derailed from the algorithm if the codes suddenly look very messy and full of individual cases. At this point, you need to do backup of your codes and start over again. I know, it's a real pain to do so (especially when you're writing codes at the last minute), but it's better to hurt yourself now than when it's too late.
p/s: Bring it on, OCaml!