mercredi 1 novembre 2017

C# interface inheritance with lower level having property of its high level interface

I am currently designing a software and I am not sure about the below design I came up with whether it is a maintainable, extensible and decoupled design.

public interface IDrawable
{
}

public interface IComponent: IDrawable
{
}

public interface IContainable : IDrawable
{
    IEnumerable<IDrawable> Children { get;}   <--this property takes collection of high level interface
}

IComponent can be such as TextComponent and ImageComponent.

IContainable can have childrens of either IContainable or IComponent hence collection of IDrawable..

So question is, Is it okay for IContainable to have property of its implemented IDrawable interface?

Aucun commentaire:

Enregistrer un commentaire