Should one interface inherit another interface

后端 未结 6 1891
抹茶落季
抹茶落季 2021-01-30 12:17

I can\'t seem to find an answer on this and just want to make sure it\'s an ok coding standard. I have interface A that is used by many different classes and don\'

6条回答
  •  醉梦人生
    2021-01-30 13:01

    Interface inheritance is an excellent tool, though you should only use it when interface B is truly substitutable for interface A, not just to aggregate loosely-related behaviors.

    It's difficult to tell whether it is appropriate for your specific case, but there's nothing wrong using the practice in principle. You see it in the first-rate APIs all the time. To pick just one common example, from the .NET framework:

    public interface ICollection : IEnumerable, IEnumerable
    

提交回复
热议问题