I believe the question is self explanatory. I would rather put more focus on the example to support question.
public interface IEnumerable
{
IEnumerator GetEnumerator();
}
public interface ICollection : IEnumerable
{
void CopyTo(Array array, int index);
int Count { get; }
Object SyncRoot { get; }
bool IsSynchronized { get; }
}
public interface IList : ICollection
{
Object this[int index] { get; set; }
int Add(Object value);
bool Contains(Object value);
void Clear();
bool IsReadOnly { get; }
bool IsFixedSize { get; }
int IndexOf(Object value);
void Insert(int index, Object value);
void Remove(Object value);
void RemoveAt(int index);
}
It is clear that IEnumerable
is separate to allow only looping over collections. But I don't understand why they kept ICollection
and IList
separate? Even if they were one, IList would not become fat because that behavior would always be required by any collection?
I came across this post which says your API would return IEnumerable
if client only needed to loop of items, ICollection
if only read-only access was required and so on.
How did MSFT apply ISP so perfectly that it has never caused any issues all these years?
Is applying ISP a continued process based on client code needs or a one time application? If ISP is applied only once, then my question is in the post title itself.