Friday, June 11, 2004

Mr. Clean: Practical Experience in Cleaning Code

I have in my last 3-4 years of ColdFusion experience, frequently having been put in the position of cleaning up other people's companies work.

Which can get rather frustrating, so I want to share some of my tips and experiences so that you can help speed up the process.

1. Flow Chart It - Simply having this documentation to make sure the code continues do whatever functionality it does. Save your rear, make sure you are improving the readability, functionality of the code, without losing what it was originally meant to do.

2. Thoroughly comment - It's a pain, but it always pays off in the end, I mean, don't you want the person who works on the code some years after you have done, to have a good impression? Don't repeat the pattern of forcing coders to clean up the work of other coders.

3. Indenting - There are many different styles of indenting, but pick a style, that's reasonable, but we each have our own style. Like for example:

table blah blah
tr blah blah
td blah blah
content
/td
/tr
/table

Others like doing it like this:

table blah blah
tr blah blah
td blah blah
content
/td
/tr
/table

The key is find the style you like that is still going to be readable by others.

4. Documentation - It really pays to both document the work the previous person did, and what functionality, and then what work you did.

The goal in all of this is to help us as an industry and community to raise our standards of good coding.

And if that happens, it's much less likelier that we'll have to do more cleaning other people's code.

After all you can pick your friends, you can pick your code, but you should not pick your friend's code.

:)

1 comment:

  1. Anonymous10:50 AM

    Also remember to make use of tools like TIDY if the code is a real mess. Often times I'm asked to 'clean up' an existing site and make it presentable until we are done coding up a new site. Usually it's old school FrontPage HTML. Running it through TIDY makes quick work of at least getting the code edit friendly. A quick dash of some CSS and we're done!

    ReplyDelete