Should Helper/Utility Classes be abstract?

前端 未结 11 1979
时光说笑
时光说笑 2020-12-13 08:38

I commonly find myself extracting common behavior out of classes into helper/utility classes that contain nothing but a set of static methods. I\'ve often wondered if I sho

11条回答
  •  不知归路
    2020-12-13 09:15

    Helper / Utility methods are just fine. Don't worry about adding them to a library inside your application or Framework. Most frameworks that I have seen use them in many varieties.

    That being said, if you want to get really crafty about them you should look into extension methods in C# 3.0. Using extension method will make your Utilities a little more of a "holistic" part of your framework which it seems like what you're trying to do by considering to make them abstract. Not to mention extension method are a lot of fun to write!

提交回复
热议问题