Some Design Recommendations
Contracts are sensitive matters. This is no different for interfaces, so some design recommendations are in order to ensure you don’t paint yourself in a corner when defining interfaces or abstract base classes.
Versioning
Interfaces are particularly weak in the context of versioning of code. Once an interface has shipped and customers are implementing it, it’s a breaking change to add members to the interface in subsequent releases. Because of this, it’s never a good idea to define interfaces that do a bunch of unrelated things, as their “dumping ground” for a potpourri of members will last for only a single release. Instead, make sure an interface does one thing well.
Or Should I Use a Class?
Because of the versioning ...
Get C# 4.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.