Is it the best practice to extract an interface for every class?

后端 未结 13 2544
我在风中等你
我在风中等你 2020-12-04 17:43

I have seen code where every class has an interface that it implements.

Sometimes there is no common interface for them all.

They are just there and they are

13条回答
  •  暖寄归人
    2020-12-04 18:17

    I don't think it's reasonable for Every class.

    It's a matter of how much reuse you expect from what type of a component. Of course, you have to plan for more reuse (without the need to do major refactoring later) than you are really going to use at the moment, but extracting an abstract interface for every single class in a program would mean you have less classes than needed.

提交回复
热议问题