Re: Coding Standards



Martin Gregorie wrote:
Lew wrote:

I endorse line-wrap at 80.

Yep. An X-term console window defaults to 25 x 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
.



Relevant Pages

  • Re: Dial-up connection multiple connections?
    ... > controls number of connections for PPP? ... > Linux?? ... I do not have a low bandwidth situation to test this on so RTFM and be ... You can however inspect packets to see what window size is being ...
    (Fedora)
  • RE: Cant see workgroup computers
    ... cannot see other computers in the workgroup, ... Click Network Connections. ... Start the Computer Browser Service ... Close the Computer Management window. ...
    (microsoft.public.windowsxp.network_web)
  • Re: Parent window not closing HTTP Connections made by child window
    ... If XP try this (in a command window) ... Make a note of any connections. ... > click on any other link on PageA which is trying to open ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Possible to allow User accounts to change ICS connection (Internet Connection Sharing)?
    ... You may be able to add the users to the Network Configuration Operators Group ... connections; create or delete connections, use ipconfig.exe, and ... This will open up an explorer window with the network connections. ...
    (microsoft.public.windowsxp.general)
  • Re: Performance of TCP/IP stacks
    ... Do you find that normal keepalives are effective against Delayed ACKs? ... The probes with advance bytes are for window probing ... anti-social to hanging connections: there is simply ...
    (comp.arch.embedded)