I'm learning JAVA..

wonder

Expert
Licensed User
Longtime User
Many languages allow stacking statements on a single line. I personally never use it simply because it makes the code so much harder to read (for me at least) later on. I rarely even use single line IF statements hehe.

--- Jem
I have the same kind of approach, it give a more structured appearance to the code.
The same goes for my math expressions, regarding the order of operations. Just to be safe, I put parenthesis on everything.

For example, "x = A * C / B" becomes "x = ((A * C) / B)".
I'm fully aware that in this case it's absolutely redundant, but for more advanced expressions, it really helps keeping everything in place.
 

Troberg

Well-Known Member
Licensed User
Longtime User
Many languages allow stacking statements on a single line. I personally never use it simply because it makes the code so much harder to read (for me at least) later on. I rarely even use single line IF statements hehe.

Another comment on this:

It's not a dangerous construct to allow, as, as you say, in most cases it won't be used. In the cases it is used, it's not because someone is lazy or don't understand what they are doing, it's because they have a specific reason for doing it (usually that it gives a neater code, such as in my earlier examples).

In other words, it's a case of "breking the rules because I understand them", instead of "breaking the rules because I don't understand them".
 
Top