Static Class Design

Static classes are classes that do not contain instance members other than those inherited from Object, and do not have a callable constructor. The following guidelines help ensure that your static classes are correctly designed.

Do use static classes sparingly.

Static classes should be used only as supporting classes for the object-oriented core of the framework.

Do not treat static classes as a miscellaneous bucket.

The Environment class is a good example of the proper use of a static class. This class provides access to information about the current user environment.

Do not declare or override instance members in static classes.

If the design of a class suggests that there should be instance members, the class should not be marked static.

Do declare static classes as sealed and abstract, and add a private instance constructor, if your programming language does not have built-in support for static classes.

Portions Copyright 2005 Microsoft Corporation. All rights reserved.

Portions Copyright Addison-Wesley Corporation. All rights reserved.

For more information on design guidelines, see the "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries" book by Krzysztof Cwalina and Brad Abrams, published by Addison-Wesley, 2005.

See Also

Other Resources

Type Design Guidelines

Design Guidelines for Developing Class Libraries