This project is read-only.

FxCop CA1506 - AvoidExcessiveClassCoupling

Original Source:


This rule measures class coupling by counting the number of unique type references that a type or method contains.
Types and methods that have a high degree of class coupling can be difficult to maintain. It is a good practice to have types and methods that exhibit low coupling and high cohesion.


For the Abstract this rule is critical indicator that the usage of the different logical layers (Domain, Infrastructure Repositories, Infrastructure Providers, Application Services, Application Wokflows, UI Web, Robots) is not balanced enough.

The most common occurrences of this complaint from FxCop that we found is:
  • When you perform too much logic in a Controller Action
  • When your service executes too much in a single pipeline
  • Whenever a repository method or provider does too much

How to solve it

  • Break your method in smaller meaningful private methods. That helps a lot when you are implementing complex Application Service methods that perform big business logic.

Similar Situations

  • In past I have hear some "alright" definition that said "no more than 20 lines of code per method" should be executed. That was certainly an intuitive inclination to match this rule related to coupling or to another (very important) CA1502 - AvoidExcessiveComplexity.

Last edited Sep 9, 2011 at 2:26 AM by hudsonmendes, version 3


No comments yet.