+ 1

Should you space out expressions?

I'm used to writing stuff with mathematical operators like this: sum=foo+bar; Is it better to keep this habit or to make a small effort and get used to writing like this: sum = foo + bar; ?

17th Aug 2018, 8:47 PM
Alex Chindriș
4 Respuestas
+ 5
It doesn't matter, it doesn't even improve readability that much, just use the version you're most comfortable with.
17th Aug 2018, 9:09 PM
Maz
Maz - avatar
+ 1
some IDE's have an option to format the code which spaces out expressions, so if you're using one of those, there isn't much need to worry
17th Aug 2018, 9:09 PM
hinanawi
hinanawi - avatar
+ 1
As long as you're consistent throughout the code, it should be okay either way.
17th Aug 2018, 11:42 PM
HonFu
HonFu - avatar
0
In my own opinion, readability is quite important, and whitespaces are "free" anyway, so I prefer using spaces, even if it is a simple mathematical expression. In terms of readability, it is definitly better than the first.
17th Aug 2018, 9:07 PM
Shadow
Shadow - avatar