What are the differences between Helper and Utility classes?

后端 未结 5 430
小鲜肉
小鲜肉 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 18:51

    As Jesper said, it's entirely arbitrary. You can think of what works for your organization and make that the convention.

    For me, it's something like this:

    utils - Static class, that can be freely moved and imported anywhere.

    Doing general tasks that could be useful in different modules. As Peter Lawrey said, more specific names are useful.

    helper - Class helping another class or a module.

    Tasks that are only used in the module it's placed and won't make sense to be imported elsewhere. Hence the name could be more specific - ModuleNameHelper (e.g. AdministrationHelper, LoginHelper)

提交回复
热议问题