What is Cyclomatic Complexity?

后端 未结 15 1321

A term that I see every now and then is \"Cyclomatic Complexity\". Here on SO I saw some Questions about \"how to calculate the CC of Language X\" or \"How do I do Y with th

15条回答
  •  执念已碎
    2020-12-07 20:34

    Cyclomatic Complexity really is just a scary buzzword. In fact it's a measure of code complexity used in software development to point out more complex parts of code (more likely to be buggy, and therefore has to be very carefully and thoroughly tested). You can calculate it using the E-N+2P formula, but I would suggest you have this calculated automatically by a plugin. I have heard of a rule of thumb that you should strive to keep the CC below 5 to maintain good readability and maintainability of your code.

    I have just recently experimented with the Eclipse Metrics Plugin on my Java projects, and it has a really nice and concise Help file which will of course integrate with your regular Eclipse help and you can read some more definitions of various complexity measures and tips and tricks on improving your code.

提交回复
热议问题