Are empty abstract classes a bad practice, and why?

后端 未结 11 1929
南方客
南方客 2021-01-02 01:17

We have several empty abstract class in our codebase. I find that ugly. But besides this very stupid reason (ugliness), should I refactor it (into empty interface e.g.) ?

11条回答
  •  清酒与你
    2021-01-02 01:44

    The key is that you can extend from only one abstract class, while you can implement more interfaces.

    Apparently the "empty abstract class" design desicion was made so that it prevents the implementing class from extending from another classes.

    If it was me I'd let it go, otherwise it might break. Best is still to contact the original developers and ask for reasoning (and add them as comments in the abstract class for your and future convenience).

提交回复
热议问题