Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

While the code metrics tool gives a pretty good analysis of the code being analyzed, I was wondering if there was any such benchmark on acceptable standards for the following as well:

  • Maximum number of types per assembly
  • Maximum number of such types that can be accessible
  • Maximum number of parameters per method
  • Acceptable RFC count
  • Acceptable Afferent coupling count
  • Acceptable Efferent coupling count

Any other metrics to judge the quality of .Net code by?

share|improve this question
Please make a q& A format for these types of questions as well. There are a lot of them and they also provide a good learning and sharing opportunity, which is what this site is all about :) – user20358 Sep 23 '12 at 10:07

closed as not constructive by Jim G., gnat, Walter, Dynamic, World Engineer Sep 23 '12 at 4:16

As it currently stands, this question is not a good fit for our Q&A; format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

3 Answers

up vote 3 down vote accepted

If you're looking for actual guidelines for those, I'm not sure if there are any well-established ones.

Tool-wise, I recently stumbled across Nitriq. At the time of writing, it's free (as in beer), and is extremely easily extensible via LINQ-style queries on top of their analysis model. You could probably create a query for the metrics you mention, within a few minutes.

Edit: I would also advise against using metrics in any other way than to explore the codebase and guide code-reviews. Being forced to comply with ill-conceived, automated, artificial metrics can be quite irritating. Not every situation is the same, and not everyone agrees with specific metrics. I also tend to stick to the simpler metrics - e.g. SourceMonitor offers line of code and cyclomatic complexity measures (min, max, average, by project, class, method, etc). At a glance, this gives me 95% of what I want to know, without getting too technical. You'll notice the "red flags" immediately.

share|improve this answer
  1. Gendarme and FxCop can also give some metrics around the code in terms of method length, cyclomatic complexity, etc.
  2. Simian , for duplicates analysis
  3. Structure101 can point some useful things about the structure of the code
share|improve this answer
Perhaps you could link to the tools you mentioned? – Martijn Pieters Sep 25 '12 at 10:23
Done, thanks Martijn ! – Sruti Sep 27 '12 at 10:09

Sounds like a job for NDepend

That'll give you all the metrics you're asking for along with default (i.e. suggested) figures for acceptability. If you start wandering beyond those figures, you'll get warnings when you run analysis.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.