A statement that could be written as:
foo=(bar*5)+baz;
is usually written in sample code (documentation, tutorials etc) as:
foo = ( bar * 5 ) + baz;
This appears to require extra work and seems counter-productive to me. Is there a rational reason for this? Is this a good coding practice, or just for sample code?
(The reason I ask this is to make sure my coding style is right, and understand why most code I see online is written like this).
I don't put spaces after (
or before )
, but I know people that do; other than that it's how I would write it:
foo = (bar * 5) + baz;
I think it's easier to read, and about the tiniest amount of "extra work" you could possibly create. I used to code without much spacing and now I look back and think it looks terrible. There is no "right" coding style though; if it's your project format the source code however you want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With