C#'s stubborn restrictions are hurting the fundamental OO principle! RRS feed

  • Question

  • I have three classes, A, B and C in the same class library. "A" publishes an interface, which B and C implements. It has to be an interface not an abstract class, because B has to inherit from another concrete class, and there is this annoying restriction that a C# class can't inherit from more than one classes.

    This interface represents a set of behaviors that are purely internal within the class library. I don't want clients of this class library to see this interface and its methods. But class B and C have to have all the methods of the interface being public, because there is this annoying rule that all methods of an interface must be public, not even internal!

    So I am forced to expose this interface and all its methods on B and C to clients. They will see all these methods which are purely internal implementation within the class library, which should have all been internal! They will be confused, and if they try to call them they may get even more confused!

    So these extra restrictions C# placed on top of C++ is not doing good - it is doing the reverse - it is hurting the fundamental OO principle of minimum information exposure.

    If a one can inherit from more than one classes, or if an interface can have internal methods, then I wouldn't have to expose those internal implementation details.

    • Edited by Silan Liu Monday, November 7, 2011 3:26 AM
    Monday, November 7, 2011 3:22 AM