帮助类(helper class)用于提供一些功能,但不是其使用者(应用程序或别的类)的主要目标所在。例如在委托模式中的帮助对象(helper object)。

帮助类的一个特例是工具类(utility class),其所有方法都是静态的。

例子 编辑

C#的一个工具类例子


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 + "!";
    }
}