codeRambler Ramblings on code, the web, and technology

It doesn’t smell right!
Thursday July 05th 2007, 2:38 pm
Filed under: Agile, Javascript, Web development

How often do you refactor your code so that it works better or is easier to understand? Hopefully this is a constant process where you are refining and adapting on a regular basis (note that this is not quite the same as just rewriting code for the sake of it). Recognising that a section of code “smells” and needs to be refactored is not a particularly straight-forward task, some of the signs I use to spot “smelly” code include:

  • repeated blocks of the same code in different areas of the code base
  • huge long “if...else if” blocks
  • variable names that have no meaning or description of their contents
  • function names that are not descriptive of their purpose
  • code that doesn’t have supporting unit tests

Of course there will be different “smells” for different programming environments, I’m a Javascript developer and my “nose” is focussed on how my javascript code performs within web applications.

Have you sniffed your code recently to check that it doesn’t smell?

Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>