Might also have something to do with age as my eye sight isn’t the best, and I find bunched up code much more difficult to read and follow. Especially ))))) how many parenthesis are that again?
Funnily enough in xDev Tips&Tricks I argued FOR spacing
Nope. Might it have something to do with me reading it on an iPad?
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))))
// vs
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.
Spaces or not, that many parens is hard to comprehend at a quick glance, thus shouldn’t happen in real code. Refactor and that reasoning becomes invalid.
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 True
Else
Return False
End If
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.
You make a point, but what if I only want to break on True or False. The first example gives me the most flexibility to debug my project and I doubt there’s any optimization difference between them.
[quote=246420:@Norman Palardy]You can see it
The line just isn’t quite as simple to read as “return true”
Its why we often get questions about some code that is like
[quote=246421:@Jeremy Cowgar]That should be written as:
dim b as boolean = (x = y)
:-D[/quote]
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.
Write accordingly