Working in a brownfield project means that you have a version of the application running in production, probably a large amount of bugs to fix, some new features to add and a lot of places where the code could be improved.
So now the question is: how can we convince our manager to let us spend some of our time improving the existing code instead of adding new features?
Certainly that is not an easy task, but here there are some good reasons to do it:
- Experienced developers don't want to touch messy codebases, so your manager will end up having a lot of junior developers and staff turnover.
- Changing existing features or adding new ones is easier when the codebase is clean (and probably the amount of time required is less).
- When developers are proud of the codebase, they are more committed with the quality and don't let anyone to mess it up.
Here you have a list of metrics that can be useful in a brownfield application (for more details, see chapter 5 of the book):
- Code Coverage: percentage of the code that is covered by tests.
- Cyclomatic Complexity: how complex is the application, measuring the numbers of paths in the code (if, loops).
- Class Coupling: how dependent are the classes on other classes (there are two types: afferent and efferent).
- Cohesion: how strongly-related are functions and responsibilities.
- Distance form the main sequence: using abstractness and instability determines which classes are in the zone of pain and which ones are in the zone of uselessness.
- Depth of inheritance: how many levels of inheritance the classes have.
- Maintainability Index: using complexity and lines of code determines how maintainable the code is.
Selecting and measuring some of these metrics will help you to understand which are the pain points and will allow you to show your manager the improvements the team has done.
For more information about metrics you can check this post of Scott Hanselman and this document about NDepend metrics.
As a final thought, just a warning, metrics are just that: metrics. They should be applied with common sense. Be careful managing the manager's expectations and be sure that the entire team agrees with them.