DEV Community

Discussion on: What habit do many senior engineers have that juniors should try to avoid adopting?

Collapse
 
jdforsythe profile image
Jeremy Forsythe

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.

Collapse
 
sunnysingh profile image
Sunny Singh

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