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

I find that I consciously need to go over any code and rewrite it with a reader in mind. The first version is usually crap, but at the same time, it's very easy to fall into the trap of making it Just Right which makes the second version "super elegant" but completely opaque at the same time.

I often end up making a "super elegant" version and, almost invariably, end up scrapping it for a (hopefully...) more bread-and-butter version, which may or may not incorporate some lessons learned from the concise version. Even if not, it's not all loss, because coming up with the elegant version is intellectually rewarding and super fun.

Add lots of in-line (not just scaladoc) comments helping the reader along. Extract vals for intermediary steps. Variable naming is always important, but even more so when you don't explicitly declare the type.




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

Search: