vendredi 27 janvier 2017

Is it right usage of interfaces?

I think about such usage of interfaces in c#. Is it right usage of interfaces?

public interface IAnimal
{
    int LegsCount { get; }
}

public interface ICat : IAnimal
{
    string Voice { get; }
}

public abstract class FourLegsAnimal : IAnimal
{
    public int LegsCount => 4;
}

public class DummyCat : FourLegsAnimal, ICat
{
    public string Voice => "I am dummy cat";
}

This code works, but I don't know, whether I should use this technique.

Aucun commentaire:

Enregistrer un commentaire