I work with a person who is often NOT careful in his work. Beyond that he does well. When he asks “How can I be more careful?”, We usually answer. “That is up to you to figure out” After some thought, I’m not sure this is the right approach.

Those of us who think of ourselves as careful and methodical sometimes assume this habit is innate. We forget what it was that made us careful. Perhaps it was a teacher who kept returning our work until it was without error. Perhaps was it getting tired of spending years of flailing around. Perhaps it was a textbook on mathematics.

Because we forget what made us careful, we assume people who are not careful can never learn this habit.

Here is a list of questions, a sort of checklist to help a person become more careful.

Personally, I find it better to imagine that I will have to maintain my code, six months from now. Finding the intersection between yourself and the psychotic axe murderer is left as an exercise for the reader...

Not really. I've worked with people who can describe at length what they are doing and why it works and how wonderful it is... but what they've typed in isn't that. There is a pattern of failure, not seeing the actual code for the glow of what it was _meant_ to be.

I've sometimes wanted to ask them to get up, walk around the room, sit down again and *read* what they've typed.

There are some folks who seem obsessed with the details of whatever they are doing and others that really don't even see that level of detail. It can be a personallity trait. Those who see only the details are not generally good at being in charge of a bunch of others, and those who are good leaders are frequently poor at details. It's important for people to work in areas where there personalities fit what they do.

Relating this to recent projects involving updates and additions to other people's code, it reminds me of ways to both test legacy code and document my own.

In testing legacy code:
- Is it still in use? If not, why?
- What's the scope? Exactly where will this work and where will it fail?
- Is the author still around so I may ask questions?
- Is it worth figuring this out and updating it, or would I be better off starting over?

In documenting my own code:
- What does this code do and why was it created?
- Include a history section that documents changes and dates.
- Add a simple outline if it's complex so it's easy to understand it without studying all the code.
- Document the code assuming you'll be trying to understand it two years in the future and you don't remember anything about it.

Isn't this what change-control (such as CVS or SourceForge) is for? I would use CHANGES sections for release notes and keep version changes relegated to source control. Otherwise, the source file gets too cluttered up!

------We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Is the question "How to be a more careful coder" or the more general "How can I be more careful in my work?". One is much broader than the other.

let's try a few broad rules

1) Put the user's shoe on.
Listen and understand what is being requested of you, and why it is imoportant to the requestor.

2) First do no harm. Does everything you didn't intend to touch work just like it did before?

3) Make personal back ups of all things to be changed BEFORE working on them. Paranoia is the basis of good programming, trusting backups of others is like asking someone else to do your tiedown in mountain climbing.

4) Users shoes again - Test the software pretending you will be able to do your job ONLY through this software. test over and over. Remember those little annoyances that would make you crazy, will make the user crazy.

5) No surprises. Pretend I am doing some work for you. When would you prefer to hear the following:
I'm running late.
It works differently than discussed.
It's slower than anticipated.
Your changes will affect the due date
** bad news early allows the user to plan accordingly, bad news late allows/forces the user to blame you.

System administration is sometimes the art of solving problems of which you don't know the source. For that kind of problems, I wrote my own checklist based on my personal experience: it's a four-phase analysis I run through until I find the problem.

at first, don't trust the user;

then, don't trust the computer;

then, don't trust the OS;

if all this fails, don't trust yourself.

Ciao!--bronto

The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).--John M. Dlugosz

When putting a smiley right before a closing parenthesis, do you:

Use two parentheses: (Like this: :) )
Use one parenthesis: (Like this: :)
Reverse direction of the smiley: (Like this: (: )
Use angle/square brackets instead of parentheses
Use C-style commenting to set the smiley off from the closing parenthesis
Make the smiley a dunce: (:>
I disapprove of emoticons
Other