re: What habit do many senior engineers have that juniors should try to avoid adopting? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Avoiding clever code. You feel smart writing clever code, and you may even justify it by saying it's less code. However, code should be explicit a...
 

I totally agree. Writing code is an art and, like painting, there are many styles.

When painting something abstract, the artist surely knows not all viewers will understand the painting. When writing code, you should strive to paint photorealism, where the code can't be misinterpreted.

There are times where obscure code can't be avoided, though. If it's convention in a framework you're using, for instance, then it's okay because later coders should understand the convention. Otherwise, it's a perfect opportunity for an explanatory comment. This also helps you not try to be "clever" because writing the comment nullifies any handful of keystrokes saved by being so.

 

That's a good point. If you must write clever code, then at least provide a comment explaining why that code is there.

code of conduct - report abuse