Is having an empty base class bad design?

后端 未结 4 905
耶瑟儿~
耶瑟儿~ 2021-01-12 10:24

I need a base class for my DTO classes which will be used in my generic interfaces.

But the DTO classes have nothing in common. They are just dumb classes containing

4条回答
  •  深忆病人
    2021-01-12 10:55

    If they have nothing in common, what are you going to do with the instances you retrieve from your list?

    In any case, having the base class means that when (okay, if) you identify something they do need to have in common later on, you don't have to go back and refactor (re-base) everything. But I'd consider using an interface rather than a base class for this sort of thing in any case, as it doesn't sound like there's a strong need to reuse underlying implementation (as they have nothing in common yet!). It'll depend on what you think they may end up having in common later on.

提交回复
热议问题