What are the differences between Helper and Utility classes?

后端 未结 5 396
小鲜肉
小鲜肉 2021-01-29 18:12

How determine how call a class XHelper or XUtils ?

To my mind :

Helper class, is a class that can be instantiate and do some business work

5条回答
  •  太阳男子
    2021-01-29 19:00

    A utility is a "leaf node" class of general use. That is, it doesn't have any dependencies into your project and can be ported from project to project without breaking or becoming useless. Examples: Vector3, RandomNumberGenerator, StringMatcher, etc...

    A "helper" seems to be any class whose design is to aid another class. These may or may not depend on your project. If you're creating a GameNetworkClient class, you could say the GameNetworkConnection class is a 'helper', because it "helps" the GameNetworkClient.

    The way developers refer to tools reflects common usage of these words. If you can recall hearing tools described as "helpful" vs "useful", a helpful tool tends to have some context (cheese grater helps to grate cheese, corn stripper helps to strip corn, speed loader helps to reload a firearm). A "utility" is expected to work in a variety of contexts (WD-40, duct tape, army-knives, glue, flashlight, etc...).

提交回复
热议问题