MonoDevelop Code Metrics and Cyclomatic Complexity

Hi everyone.

I’ve just discovered Monodevelop has a feature that lets you calculate some code metrics automatically, one of which being Cyclomatic Complexity. It’s a new concept for me, but after doing a bit of reading I am intrigued. From what I have read it is best to keep the complexity at around 10, but I’d like to know how (if at all) this differs when doing some game development.

Monodevelop also calculates many other metrics and I thought it would be interesting to get people’s opinion on their popularity / usefulness. :slight_smile:

I myself am quite new to code metrics, I haven’t ever gathered any previously and so far all they have told me is where my code is most inefficient, which I kinda know already after writing it inefficiently! So for me I have yet to find a good use for them. :stuck_out_tongue:

The best cyclomatic complexity is 1. Meaning: Your program runs top to bottom without any ifs and loops. Of course you wont get much done in there. The higher the complexity, the harder your code is to read. It will get really hard to understand if you are constantly above 10. Code metrics are mostly not tools to discover inefficencies, but unreadable code. So if you are developing in a big team, its a good idea to use metrics to discover badly written code. Then you can refactor it and improve its maintanability.
If you are developing alone though, their use is limited.