It is a solution to the classic program formatting dilemma.
First a couple of examples;
// Java StandardThe above illustrates the difference between the 2 notations. The first, the IBM Standard Java format, is something I've never really liked since everything looks so bunched up - bunched up code is much harder to read - I end up putting random whitespace in anyway, but with no level of consistancy.
try {
XMLDocument response = agent.request(xmlRequest, logger);
} catch( FailureReport failureReport ) {
throw new GSSystemException(failureReport);
}
// C/C++ Standard
try
{
XMLDocument response = agent.request(xmlRequest, logger);
}
catch( FailureReport failureReport )
{
throw new GSSystemException(failureReport);
}
The C/C++ notion is much better in terms of readability, but doesn't have the symemtry of the Java Standard and suffers from a fatal flaw; it's not Java Standard!! :)
But we have the solution! How to write *almost* standard Java code with out any of the issues;
// Colin's much better methodAs you can see, it's exactly the same as the C/C++ notion, but with the brackets at the end, a la Java Standard but with the whitespace preserved... see what I mean about it being obvious?
try {
XMLDocument response = agent.request(xmlRequest, logger);
}
catch( FailureReport failureReport ) {
throw new GSSystemException(failureReport);
}
The great thing is the only bit that isn't really standard is the fact that the "catch" clause is dropped to the next line - but I'm not sure that is specified anyway, since I've since lots of code with the dropped line... and no - I can't be bothered to check!
No comments:
Post a Comment