I have been doing programming as a consultant a little over a year and half. While working last year, I realized that there are a couple attitudes that most consultants have that I think all programmers would do well to adopt, or at least think about.
* First off, make sure your code is written in such a way to be easily readable and well-commented. The programmer reading the code and trying to figure it out 6 months later may be you! This will also made the code easier to maintain and debug.
* Document as you go. This relates to the previous point. There's never time to document a project after it is done, but if you do a few minutes a day as you are developing, it won't be so bad.
* Keep an ongoing list of features you want to add and bugs you want to fix.
* Realize you won't be working on any specific program forever. You should have a plan for handing the work you've done off to someone else. People get promoted, transferred to other projects, get better jobs, get laid off, and sometimes get hit by a bus (see last item).
* Always make sure you are learning new things and coming up with ideas on how to do things better.
* Know who your customer is & be sure your work is serving them. As a consultant, your customer is your client. As an employee, your customer is your employer, your boss, or whoever is going to be the end user of the program you are creating.
* Last of all: everyone says you should document things & share information so if you get hit by a bus, people will know what they need to know to continue the project. This point is brought up often enough, programmers should generally just avoid buses, just to be safe. Take the subway or train instead. No one talks about programmers being hit by them.