My home network

At home, my main workstation is a 400Mhz AMD K6 running Debian (currently woody, but I can also boot into sid if I’m feeling daring). It also has FreeBSD, OpenBSD and an old unloved version of Debian GNU/Hurd installed.

We’ve also got a server running Debian (woody/stable), an Gateway Pentium Pro 200 MHz, which handles our email, databases and web developement, and other useful services like DNS and DHCP.

There’s also a couple of laptops (untethered courtesy of NetGear 802.11b cordless ethernet cards).

Connecting it all the outside world is a cable modem and a dedictated firewall/NAT gateway (OpenBSD on a Compaq Pentium 100 MHz). My heartless wife will not let me get more computers. :(

Printing from windows with samba and cups

The default debian (woody) config of cups didn’t quite allow this to work… make the following changes (to enable raw printing via the windows driver):

Uncomment line 83 in /etc/cups/mime.convs:

#application/octet-stream        application/vnd.cups-raw        0       -

and also uncomment line 152 in /etc/cups/mime.types:

#application/octet-stream

Also, we need to add the following (rarely mentioned) line to smb.conf (in the [Printers] section):

use client driver = yes

This will cause windows to successfully get the printers’ status.

How not to comment your code

Below is a piece of code I came across recently while reviewing somebody else’s work. It is a terrific example of how not to write comments.

//Create a vector
Vector seq = new Vector();

//Count the number of items in the sequence
int count = ms.itemCount();

//Loop through the sequence getting all the values
for( int i = 0; i < count; i++ ) {
    //Convert the item to an Instance
    MInstance mi = (MInstance)ms.getAt( i );

    //Convert the instance to a HashMap
    Map data = mInstanceToMap( mi );

    //Add this to the Vector
    seq.addElement( data );
}
//Return the vector
return seq;

Ignoring for the minute the infuriating habit of putting spaces around parameters (doesn’t anybody read the Java style guide any more?), these comments are completely useless.

There are plenty of places to learn how to write comments. A couple of references come to mind: Steve McConnell’s “Code Complete”, “The Pragmatic Programmer”, “Programming Pearls”.

In a nutshell… don’t write comments that say what the code is doing (you can safely assume that anyone likely to need to read your comments is at least borderline literate in the progamming language in question). Maybe explain why your code is doing it, and defintely document any assumptions. Please don’t tell me new Vector() creates a new Vector…