JoiWiki » Developer » Programming Concepts » Core Concepts » Classes and their Features Classes and their Features

Classes and their Features

Classes and their Features

Classes are a fundemantal building block for Object Oriented Programming, they're incredibly flexible and can be used to represent anything that the developer/system designer wants. Wikipedia describes a class as:

a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods).


That is to say that a class definition describes the features of an object and the associated data items (properties), allows a way of creating an instance of that object if allowed (a constructor) which often gives the ability to set the initial state of the class instance, and defines behaviours (methods/functions/procedures) specific to that class.

 An instance of a class is like a copy, you create a new version of that class in a variable and can set the properties to values specific to that instance. As many instances can be used as can variables within a given scope, each holding unique data. Some classes do not allow for instances to be created, an example of when thois may be useful is when grouping together helper methods.


Common Features

The implementation of classes, their features and the language used to describe them changes between programming languages and as I generally use these concepts in a C# environment I'll use the terminology relevant to that language but these features are intended to be more universal. Here's a very simple class definition, again it's in psuedo C# syntax but what it describes is common pretty much across the board:





All languages that claim to be object oriented must support class inheritance. In a nutshell this means that a class can inherit the features of another, whilst offering the ability to override or add to any of the properties or methods offered by the parent class (or base class), the structure of class inheritance is called the class hierarchy. Ineritance is a fantastic way to keep to DRY principles (Don't Repeat Yourself), as in the often used example of inheritance of a Person class offering the following:



Created by system. Last Modification: Tuesday January 15, 2019 21:34:17 GMT by JBaker.