Is there anything wrong with a class with all static methods?

后端 未结 16 1093
余生分开走
余生分开走 2021-01-30 16:43

I\'m doing code review and came across a class that uses all static methods. The entrance method takes several arguments and then starts calling the other static methods passin

16条回答
  •  心在旅途
    2021-01-30 17:06

    One of the disadvantages of using a static class is that its clients cannot replace it by a test double in order to be unit tested.

    In the same way, it's harder to unit test a static class because its collaborators cannot be replaced by test doubles (actually,this happens with all the classes that are not dependency-injected).

提交回复
热议问题