See
My OO Presentation Notes as a preface.
“In short, a class is a blueprint for an object” (Weisfeld, 2000). A class is a template for defining an object. When we instantiate an object, we use a predefined set of instructions describing how to build the object. A class is a data type, used to define data and behavior representing a concept. Classes support inheritance, a concept that will be covered later in this article. Classes are the building blocks of object-oriented programming.
To further define the class, it is a data structure that may contain the following: data members (constants and fields), function members (methods, properties, events, indexers, operators, instance constructors, destructors and static constructors), and nested types. (Microsoft, 2006). Classes describe a collection of encapsulated variables and methods. Encapsulation is another important principle of OO that will be covered further in this document.
A class is not an object. Objects and classes are used synonymously, but an object could not exist without the class to specify its definition. A class defines a type of object. When we create a new instance of a class, we are creating an object that exhibits all the characteristics of the class.
Classes can inherit from other classes, and implement interfaces. In C# and Java, a class can extend only one class, but it can implement one to many interfaces. When a class inherits from a base class, it derives characteristics from the base class that become part of the new class. When a class implements an interface, it enters into a contract in which the class must provide the events, methods, properties, and indexers declared in the interface. The class fulfills the contract by providing the implementation set forth in the interface declaration.
Types of Classes
Classes can be abstract, final, static, and concrete, among others. An abstract class is a class that cannot be instantiated. Abstract classes may declare some functionality, but are incomplete, and rely on derived classes to provide their implementations, and create object instances. They are useful in design hierarchies, and as base classes for which concrete, or derived classes, extend functionality. Abstract classes typically contain one or more abstract methods or properties which are not implemented. Derived classes must override the abstract methods and properties and provide their implementations. A virtual method in an abstract class is one that does provide an implementation, and allows the derived class the choice to override that functionality, whereas an abstract method provides no implementation and must be overridden.
Final classes and methods are those that cannot be extended by derivation. In C#, a final class is a sealed class. A final class cannot be inherited. Final methods and properties that are not part of a final class override their methods in the derived class.
Concrete classes are simply classes that are object instances. These classes are the implementations of base classes, inheriting their characteristics, and providing a functional instance. In a concrete class, all of its methods have implementations.
Static classes and class members are used to create data and functions that can be accessed without having to create an instance of the class (MS Static, 2006). Static classes and members are useful when functionality is needed that is not dependent upon an object’s instance.
References:
Microsoft. (n.d.). Retrieve May 19, 2006, from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_10.asp
MS Static. (n.d.). Retrieve May 19, 2006, from http://msdn2.microsoft.com/en-us/library/79b3xss3(VS.80).aspx
Weisfeld, M. (2000). The Object-Oriented Thought Process (1st ed.). Indianapolis, IN: Sams Publishing.