Helper class

In object-oriented programming, a helper class is used to assist in providing some functionality, which isn't the main goal of the application or class in which it is used . An instance of a helper class is called a helper object (for example, in the delegation pattern).

Helper classes are often created in introductory programming lessons, after the novice programmer has moved beyond creating one or two classes.

A utility class is a special case of a helper class in which the methods are all static. In general, helper classes do not have to have all static methods, and may have instance variables and multiple instances of the helper class may exist.

Example

This is also an example of a utility class.

public class PrependHelper
{
    // static functions
    public static string MeowPrepend(string text)
    {
        return "Meow meow " + text + "!";
    }

    public static string WoofPrepend(string text)
    {
        return "Woof woof " + text + "!";
    }

    public static string WoohPrepend(string text)
    {
        return "Wooh " + text + "!";
    }
}

See also

This article is issued from Wikipedia - version of the 10/25/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.