C# SimCity with SharpMetrics
Do you ever think of software architecture? How would you represent the structure of a software? There are many ways to do this. One of which is using a city metaphor.
The idea is simple: picture a geometrical block, which length, width and height are defined by a software quality metric each. Each block represents a class with - for example - number of attributes (NOA) as width and length and the number of methods as height (NOM).
- A tall big building is probably a god class, a class with a lot of methods and a lot of attributes and probably knows too much about the world
- A tall thin building is probably an interface with a lot of "empty" methods
- A small house is probably a "clean" class, that respects the single responsibility principle - SRP
This, of course, oversimplifies the whole use of the software, but you got the point. Mixing those metrics, you can make classes stand out as tall buildings and thus automatically identify so-called "disharmonies", among which (not yet all implemented in SharpMetrics):
- Feature Envy: methods that are very interested in other classes
- Data class: aggregate data but contain little behavior
- God class: interacts with many other classes with high complexity
- Brain method: method with high complexity that dwarfs the rest of the class
- Brain class: a class containing a lot of brain methods
- Significan duplication: a high degree of code duplication
This really brings a different view on your architecture and can help you get an overview of a new project. I'd really recommend to give it a try!