views:

58

answers:

0

In this video after approx 35 minutes Krzysztof Cwalina (Micrsoft's .NET Framework Program Manager) talks about distinguishing library, abstraction and primitive types in their design process.

Examples of each:

  • Library types are at top layer: Diagnostic.Debug, EventLog
  • Primitive types are at bottom, have minimal interface and supposed to transfer information between components: System.String, Int32
  • Abstraction types: ICollection

  • When to expose some type through interface or pack behaviour in some primitive data container (or both)?

    Think of BCL was designed in such a way that System.String would be an interface.

    interface IString : IEnumerable<char> {
      char this[int index];
      ...
    }
    

    In this case other API would accept IString and not System.String

    void Format(this IString message, params object[] args) {...}
    

    So whether there should be an interface you your library or not is a stuff to think about. There may be exposed both interface and type (string and IString). But Microsoft choosed to expose only the System.String (and no IString).