The "Coding Standards" is an interesting issue in it's own right - I am tempted to start a new thread just to talk about it. On second thoughts, no - someone else's turn to start theoretical topics if they want to.
Originally posted by Michael Fitzmaurice:
So, Mark, what made you switch to end of line (I assume this is what you now use)?
[ October 10, 2003: Message edited by: Michael Fitzmaurice ]
Another aspect of making the assessor’s life easier is what you’ll learn in Chapters 11 and 12. The little things really matter! For example, while you might think—if you indent your code four spaces—that an occasional three-space indentation here and there is OK, what’s the harm in that? The harm is in readability, and while a couple of inconsistencies in indentations might not be a big deal, adhering to the Java Coding Conventions is absolutely crucial for others looking at your code…
especially the assessor.
We’ve seen people fail the exam because they put the curly braces on the line below the method declaration rather than immediately following the declaration (on the same line), violating the official Java Coding Conventions. While this infraction alone probably might not cause you to fail, the points deducted for code convention violations might be the ones that sink you where you otherwise might have squeaked by. You don’t get to make very many mistakes in this exam. Just because your manager or your co-workers are tolerant of a little sloppiness here and there, the assessor won’t be.
I think that makes a pretty strong statement about following Sun's standards.
Michael I was quite surprised to see that Sun actually include [style of braces] in their standard, given its contentious nature.
Michael I have absolutely no intention of getting into a religious war about whether end of line is better than next line (especially since I suspect next liners like me are a minority on this one...)
Come to think of it, I wonder if the examiner runs your code through something similar to CheckStyle, in order to see how closely you adhere to the standard? It seems fairly likely.
Jim I don't know if they actually do still take off points
Jim And I'd have no problem with them taking off points for having an inconsistent coding style.
Andrew This way you can stop all arguments: if the company you are working for has standardised on the Sun style, then it is explicit where the braces go.
and any experienced developer is smart enough to know that forcing coding standards such as these causes more harm than good.
4 - Indentation
Four spaces should be used as the unit of indentation. The exact construction of the indentation (spaces vs. tabs) is unspecifed. Tabs must be set exactly every 8 spaces (not 4).
Do I just stick to spaces?
I will open the floodgates of his own worst nightmare! All in a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton