Re: Coding Standards
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Fri, 31 Aug 2007 16:52:04 -0400
Martin Gregorie wrote:
Lew wrote:Yep. An X-term console window defaults to 25 x 80.
I endorse line-wrap at 80.
I normally edit source with microEmacs or vi, view it with less and search it with grep, so compatibility with the default window size matters to me.
The exception probes the rule:
Sometimes if only a semicolon or close-parenthesis,semicolon sequence falls past the 80-column mark, I'll not wrap it. Console windows and most editors will wrap it for me, and there is little semantic confusion thereby.
I also indent with spaces, not tabs.
Another trick someone showed me years ago for in-code comments (as opposed to Javadoc comments) is to start them at some defined position, say, column 45 (1-based). Then you can read down the right side of the source listing and see comments, down the left side and see code.
Sort of like:
/** Javadoc comments here. */
public void foo()
{
doSomething(); // do a vital thing
cleanUp(); // close all connections
logResults(); // log to system-defined output
fireEvents(); // notify registered listeners
}
Slash-star comments are good to introduce "paragraphs" of code with "paragraphs" of comment:
/* Initialize all connections.
* Important to log any errors here.
* INFO level used for additional diagnostic information.
*/
Connection cDb = openDbConnection();
Connection cXo = openXConnection();
...
--
Lew
--
Lew
.
- Follow-Ups:
- Re: Coding Standards
- From: Mike Schilling
- Re: Coding Standards
- References:
- Coding Standards
- From: davidsamith@xxxxxxxxx
- Re: Coding Standards
- From: Sanjay
- Re: Coding Standards
- From: Wildemar Wildenburger
- Re: Coding Standards
- From: Jeff Higgins
- Re: Coding Standards
- From: Lew
- Re: Coding Standards
- From: Martin Gregorie
- Coding Standards
- Prev by Date: Re: Nightmarish XML Classloader issue with Tomcat
- Next by Date: Re: Coding Standards
- Previous by thread: Re: Coding Standards
- Next by thread: Re: Coding Standards
- Index(es):
Relevant Pages
|