Visual Studio Code Metrics and the Maintainability index of switch case

Posted by pee2002 on Stack Overflow See other posts from Stack Overflow or by pee2002
Published on 2010-05-29T22:34:09Z Indexed on 2010/05/29 22:52 UTC
Read the original article Hit count: 470

Hi there!

As a person who loves to follow the best practices,

If i run code metrics (right click on project name in solution explorer and select "Calculate Code Metrics" - Visual Studio 2010) on:

    public static string GetFormFactor(int number)
    {
        string formFactor = string.Empty;
        switch (number)
        {
            case 1:
                formFactor = "Other";
                break;

            case 2:
                formFactor = "SIP";
                break;

            case 3:
                formFactor = "DIP";
                break;

            case 4:
                formFactor = "ZIP";
                break;

            case 5:
                formFactor = "SOJ";
                break;
        }

        return formFactor;
    }

It Gives me a Maintainability index of 61

(of course this is insignificant if you have only this, but if you use an utility like class whos philosophy is doing stuff like that, your utility class will have the maintainability index much worst..)

Whats the solution for this?

© Stack Overflow or respective owner

Related posts about index

Related posts about maintainability