Tuesday, July 07, 2009

Legacy Code Sonar Signature

In "Working Effectively with Legacy Code", Michael Feathers gives this definition:
To me, legacy code is simply code without tests.
He also adds:
I've gotten some grief for this definition.
Indeed, defining legacy code is hard.

After purging one of our project from code that we consider legacy (deprecated, EJB2...), we noticed this interesting trend in our Sonar dashboard:

Notice how code coverage is way less affected than complexity and rules compliance. Our legacy code had test coverage, not the greatest ever, but it had some.

Therefore, I am wondering if we could then postulate that legacy code is code that has fallen short of software development standards?

This is actually what is expressed by the above graph: ditching legacy code drastically improved compliance to standards expressed as acceptable complexity and compliance to coding rules. These standards evolve over time: as legacy code is left abandoned, it slowly drifts away and gets less and less compliant by just standing still.

Have you noticed similar trends?

1 comment:

Josh Devins said...

Fantastic! I can only imagine what "legacy code" this is, although I can guess from the version numbering ;) Looking forward to installing Sonar at Nokia to see what happens.