Class Guidelines


Do keep a class to serve a single purpose/context only. Do NOT hoard a bunch of properties/methods with different contexts into a class.

// correct 
public static class UrlHelper
{
    public static string[] Split(string url);
}

public static class FileHelper
{
    public static string[] Split (string filePath);
}

// avoid
public static class GeneralHelper
{
    public static string[] SplitUrl(string url);
    public static string[] SplitFilePath (string filePath);
}

Do NOT define public constructor in an abstract class. Define a protected constructor instead.

// correct
public abstract class BaseComponent
{
    protected BaseComponent
    {

    }
}

// avoid
public abstract class BaseComponent
{
    public BaseComponent
    {

    }
}

Do provide at least one concrete class that insherits from an abstract class. If the abstract is not used anywhere, please remove it.

public class WebComponent : BaseComponent
{

}

Do use static class as a supporting utility/helper only. Do NOT treat it as micellaneous bucket.

public static class UrlHelper
{
    public static string[] ParseUrl(string url)
    {

    }
}

Do provide at least one class that implements an interface. Please remove it if it is not used anywhere.

public class ProductService : IProductService
{

}