In regards to spaces or not, it’s an endless debate and Kem may find this hard to believe, but I think there is no right answer. If you were raised on southern corn bread, it’s far better than anything you’ll find in the north. Raised on northern corn bread? The southern stuff stinks!
You get use to what you see and anything different is harder to read. I personally looked at the example:
Str( Max( Min( x, Abs( y ) ) ) )
and was immediately confused at the later. Trying to parse all that information in my head. It looks like a complete mess to me. My head just doesn’t work when reading it. Why? Because it’s the wrong way to code? No. Because I’m not use to it. The first line of code in that example is cake to read. I can read it without even thinking. The second line, I actually wind up scanning the line forward and back.
Now, that being said… I actually think both of those lines are wrong, but not because of the parens but because anything deeply nested is hard to read, hard to debug.
Also, you guys are forgetting that there is a crowd out there that would prefer
One more thing… The only way there is a wrong or right is if there is a set standard for the project you are working on. If your project says no spaces on the inner parens, then it’s wrong.
Another way it’s wrong, is if the community has a standard (written or not). It’s nice to write code that the community can easily read, understand, use and share. If the community has 10 different formatting standards, it’ll be a community that will have problems growing.
I’m surprised it actually works - doesn’t max require two arguments?
Isn’t all a matter of taste though? Consider this
If x = y Then
Return x = y
Return If(x = y, True, False)
All three do the same job, but the first example allows you to set break points on the return value - very useful when debugging, and with autocomplete the difference in the number of keystrokes is minimal.
To me code readability is the most important consideration, and that is rather personal. The C type languages all look like bovine fertilizer to me due to my commercial experience with COBOL.
[quote=246421:@Jeremy Cowgar]That should be written as:
dim b as boolean = (x = y)
The fact that so many folks are confused by that idiom, with or without parens, assures me that writing code that is highly readable is MUCH more important that trying to write code that is dense so “it runs fast”
Been there done that and had to audit my own code literally 10 years later and was darned glad I wrote using long variable names, explicit if then else’s instead of some of the cool short cuts the specific language in question allowed
I’d still be there picking it apart if i had
And even after 10 years fixes were easy
Remember that in 6 mos there may be some crazed psychopath who has your home address that has to READ and fix your code.