TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why You Should Always Comment Your Code

2 pointsby deconqover 12 years ago

1 comment

mseebach2over 12 years ago
That's an extremely bad example - why would cat <i>ever</i> fall through to dog? At least come up with a situation where fall through makes sense.<p>Generally, IMO, it's a much better idea to use meaningful constants and method names.<p>So the code becomes:<p><pre><code> switch(action) { case CHECK_AND_FOO: check(); case FOO: foo(); break; default: llama(); } </code></pre> Now, Joe would not only know not to add in a break, but also <i>why</i> - all without adding a single comment.