Java Reference
In-Depth Information
does occur, raise the issue as a design decision and document all the assumptions you made
to deal with the problem. Be certain to complete the design decisions document, because it is
the only chance the test allows you to defend your submitted project.
Tip It is worth noting that in the Sun assignment, as with projects in real life, there are sometimes several
solutions to any given problem. It is also possible that for every possible solution there will be reasons why
that particular solution is not optimal. You should not spend too much time trying to find the “one perfect
solution”—it may not exist. Sun has deliberately left enough vagueness in the assignment instructions that
there are very few areas where candidates have limited choices. In all other cases, it does not matter so
much what choice is made, but it does matter how you came to your choice, which should be detailed in
your design decisions document.
Java Coding Conventions
One of the common goals in our industry is the ability to hand over the project to someone
else—let them do any maintenance in the future, as you won't be available (you will be work-
ing on more exciting projects and going on vacation).
To meet this goal, the code we write needs to be formatted in such a way that you can hand
it over to somebody else, and they will happily accept it. It will not do your reputation any good
if you hand over the code, and the other person throws it all away as being incomprehensible.
In the same way, it would not do us any good if we did not organize this topic into chapters,
paragraphs, and sentences—if you can't read this topic, you won't learn much from it.
The developers of Java, C, and C++ deliberately avoided forcing coders to follow a specific
coding convention—there are syntactical requirements, but as long as you meet them, the code
can appear on a printed page any way you like it to. For instance, consider the following code
snippet:
public class MyTest {
public static void main(String[] args) {
System.out.println("Hello");
}
}
That code is interpreted by the Java compiler in exactly the same way as
public
class
MyTest{public static void main(String
z[]){System.out.println("Hello");}}
You'll undoubtedly agree that the first format is far more readable than the second.
While it is easy to agree that a code-formatting style should be followed, it is less easy to
agree on the code-formatting style itself. For example, often one person prefers to have the
brace ( { ) at the end of an existing line; another prefers to have the brace on its own line. Both
coders can have compelling arguments for their particular style, but realistically only one style
Search WWH ::




Custom Search