Fog Creek Software
Discussion Board




Check list

I've just wrote down some "clean-stuff" points
that important for me to check when code is finally working. I wonder is there any similar check lists people around here are using ?
(mine is Java-oriented)

1) All streams are properly closed in final {}
2) Objects are reused or pooled if possible
3) All parameteres received are idiot-proofed
4) Code and comments are synchronized
5) static and final used where it's possible
6) byte and short used instead of int where it's possible
7) All places where null may be returned are documented

Evgeny Goldin
Tuesday, December 25, 2001

Hi Eugeny,

My personal opinion on certain items in your list:

3) All parameteres received are idiot-proofed
7) All places where null may be returned are documented

I think that this builds down to: document your function's contract, and then check that input, output and all invariants comply with the contract. Stick to "Design by Contract" principles.

If you are using Java, I suggest you have a look at this site, you might find some useful tools in there:

  http://www.reliable-systems.com/tools/Default.htm 

6) byte and short used instead of int where it's possible

I would like to know exactly why do you think this would help at all.

Beka Pantone
Wednesday, December 26, 2001

Thank's for the link. And right, I'm adding "Design by contract" to my suitcase ..

> 6) byte and short used instead of int where it's possible
>
> I would like to know exactly why do you think this would help at all.


I think that using byte instead of int for instance and static variables (where it doesn't and won't hurt) reduces memory usage, as they're stored in heap .. So for reasonable constants like SPACES = 2 it should help.
Local variables are kept in 32-bit internal java arrays and it doesn't help to treat them as byte
or short.

There is one more point aginst this idea was given by my brother - most CPU use 32-bit registers for it's calculations, so making them work with 8-bit variables requires an additional convertions back and forth. Time penalty is paid ..

Evgeny Goldin
Wednesday, December 26, 2001

*  Recent Topics

*  Fog Creek Home