DEV Community

Discussion on: Compact or Verbose Codestyle?

Collapse
 
bosepchuk profile image
Blaine Osepchuk

I don't concern myself with the number of lines (compact vs verbose).

Code must first be readable (by a new programmer, at 5pm on Friday, operating on four or less hours of sleep). You're going to run into trouble with anything else.

I've never encountered code that was too readable. But I have encountered plenty of puzzle/mystery/deceptive/spaghetti code.

Collapse
 
georgeoffley profile image
George Offley

Same. Compacting your code, to me, is an edge case practice. Where every single millisecond counts is when that is really needed. To me anyway. Making sure your code is readable to everyone who reads it is far more important.

Collapse
 
bosepchuk profile image
Blaine Osepchuk

I completely agree.

If you're compacting your code because you want it to run faster, you are deep inside micro-optimization land. 99.9% of the time for normal programming, those kind of optimizations are not required.

And they are definitely not required throughout your code base to 'make it all run a little faster'.

Collapse
 
_joshsommer profile image
Josh Sommer • Edited

I agree with you 100%. Readable code will pay your team and you back a million times over.

I would suggest going one step farther and banning abbreviations. They can cause needless confusion. In the above example is jsonStr equal to jsonString or jsonStore? It’s much better to not have to make anybody think.