Hacker News new | past | comments | ask | show | jobs | submit login

I've got a slightly different take on messes, and using another RL analogy I call it "don't put your dirty dishes in the sink." If you have a couple dishes you can't wash right away it is tempting to put them in the sink instead of on the counter: from a distance it looks neater, any spills are contained, etc. Where this falls apart is if you add a few more dishes, and then more, and now your sink can't serve its main function because it's full of dishes, and some of them are full of dirty water so you can't just move them back to the counter, so washing just the one dish you need requires you to either undertaking cleaning the whole sink or delicately juggling the thing under the faucet while water sprays everywhere, and washing all the dishes now requires a mop.

Code messes are similar. Sweep them under a rug or toss them in a closet and your code will look clean, just like your counter looked clean while those two dishes were in the sink. And like the sink you can quickly get to the point where those closets are scary to open and no one wants to walk on that rug because it makes weird crunchy noises.

So how does one leave ones messy code "on the counter"? Well in my "writing C with vi" days I actually outdented any code that I didn't consider clean/good/permanent. Like all the way to the left, regardless of where it would naturally be indented at. It stuck out like a dirty mug on clean granite, and no one (importantly including me) failed to notice it.

With modern IDEs and auto-formatting and the somehow unavoidable use of Python I no longer use that technique, but I will comment any such code liberally with #HACK or #TODO or similar




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: