Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8081785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:50:49+00:00 2026-06-05T16:50:49+00:00

I am using MVC3. I am getting following error when I run code analysis.

  • 0

I am using MVC3. I am getting following error when I run code analysis.

CA1506 : Microsoft.Maintainability : ‘MyController’ is coupled with 94
different types from 25 different namespaces. Rewrite or refactor this
class’s methods to decrease its class coupling, or consider moving
some of the class’s methods to some of the other types it is tightly
coupled with. A class coupling above 95 indicates poor
maintainability, a class coupling between 95 and 80 indicates moderate
maintainability, and a class coupling below 80 indicates good
maintainability.

This is a controller class.

May I know what is the best solution to decrease class coupling for a controller?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:50:50+00:00Added an answer on June 5, 2026 at 4:50 pm

    As mentioned by @musefan, by the sound of it you need to refactor. I’ve just had a look at a controller in a project I’m working with which I consider to be on the borderline of lacking cohesion and needing to be refactored, and it’s coupled to about 40 types.

    Take another look at the controller and the area of your system it services, and see if you can split it up into fewer, more cohesive classes.

    Edit

    With relation to your Controller providing export functionality for Word, PDFs and Excel, I assume this means you have logic in your Controller which knows the details of putting together a Word export, a PDF export and an Excel export, including certain aspects common between the three formats which you’ve abstracted out (headers and footers).

    If I’ve understood this correctly, one refactoring you could consider would be to move all the logic relating to headers, footers, structure and formatting into a different class behind an interface, and have your Controller reference that interface instead of referencing the various classes which manage those aspects. That would move coupling to various classes from your controller into the new document-handling class behind its interface, and perhaps drop the number of coupled classes to a level below that which FxCop finds acceptable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

inside mvc3 application i'm populating dropdownlist from database using following query. getting error on
I'm developing an .NET4 webapplication using MVC3. Let's say i'm getting the following DateTime
I am using asp.net mvc 3 and I keep getting the following error. Validation
I'm using MVC3's Razor engine to generate views and have the following line of
I'm using MVC3 with C# code. I have a table in my SQL Server
I'm using MVC 3 and using the following code when the application starts... UnityContainer
I've created a new site using mvc3 and now I'm getting closer to the
I'm getting the following error Could not load file or assembly 'file:///C:\Users\<project path>\bin\DotNetOpenAuth.dll' or
I am getting the following error: The maximum message size quota for incoming messages
I am trying to use the mvc-mini-profiler with MVC3 and keep getting the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.