I'm worried I'm adding too many interfaces

前端 未结 3 1495
不知归路
不知归路 2021-02-12 09:40

I am building out my domain model and continuing to refactor it. As I do, I am finding that I like interfaces as it allows me to create reusable methods/controllers/views for c

3条回答
  •  一向
    一向 (楼主)
    2021-02-12 10:22

    The fact that you are using interfaces is a good thing. However, you should ask yourself, if I create an IEnabled interface, will I ever reference my class by that interface alone? i.e. will there be contexts where I interact with my class purely via the single property that interface exposes?

    Also, can you consider contexts where you will interact with multiple implementation of this IEnabled interface?

    If the answer to both of these question is "no", then the interface serves very little purpose.

    Having said that, please don't worry too much about this! it does very little harm.

提交回复
热议问题