This, of course, is a violation of the principle of interface segregation. ISP states that components should depend only on the interfaces that they really require. Array
implements IList
, but clearly does not need or wants, all methods defined IList
because he chooses an exception to explain that he does not support Add
. In addition, everything that he needs Array
now has IList
, despite the fact that he does not need all of his methods (since everything that the array wants to receive is clearly not worried about Add
, since it still does not work). Not supporting the operation that your interface offers you to implement is clearly an ISP violation; forcing consumer code to depend on an interface, even though it doesn't need all of this, is also an ISP violation.
. IList
, LSP , IList
. Array
, Add
.
LSP, , LSP. , , . , , Add
, , .
, NotSupportedException
, LSP. , SOLID , , , , : " ", ", " - , , , . , , , Array
Add
, , LSP.