Utility classes.. Good or Bad?

前端 未结 8 738
暗喜
暗喜 2020-12-24 15:19

I have been reading that creating dependencies by using static classes/singletons in code, is bad form, and creates problems ie. tight coupling, and unit testing.

I

8条回答
  •  鱼传尺愫
    2020-12-24 15:58

    You could always create an interface and use that with dependency injection with instances of classes that implement that interface instead of static classes.

    The question becomes, is it really worth the effort? In some systems, the answer in yes, but in others, especially smaller ones, the answer is probably no.

提交回复
热议问题