none
Challenging Question! RRS feed

  • Question

  • I've started to design a software, which simulates any theory.
    I am stuck in the next situation:
    I've declared an interface which defines both functions and properties.
    (Defining the property is a 'trick' to force implementation of a matching data
    member in classes that implement the interface)

    According to the Layered Architecture design technique, the functionality of
    an object in the objects model, is declared within the BE (Business Entity)
    layer (in the Business Logic) while the fields it contains, are declared in the
    BC (Business Components) layer. Both BE and BC are actually the BL layer.

    Now, my question is: Should I separate the functionality and the
    components of the interface, to two separate interfaces, which are
    implemented in a one interface? By this way, the classes that have to
    implement the interfaces, would implement the "unified" interface? Or all
    this stuff is just a rubbish, so it will make no big difference if the classes
    implement a one "unified" interface, or an interface which just has its
    functionality and fields left mixed together?

    Thanks in advance!
    Wednesday, March 18, 2009 11:37 PM

Answers

  • In C# we can inherit as many interfaces as we like...but only one class.  So the question to me to decide whether or not to keep the interfaces defined separately or in one interface is "will there ever be a need to inherit one interface and not the other?"  If there is every even the most remote chance that you might need to inherit interface 1 and not interface 2, then there is no reason that you can't inherit from both interfaces or create a 3rd super interface that itself inherits from both.
    • Marked as answer by miridfd Sunday, March 29, 2009 8:30 AM
    Friday, March 27, 2009 10:55 PM

All replies

  • Hi miridfd,

    Here the question is about single and multiple inheritance using interfaces.

    Inheritance is characterized as single or multiple depending on the number of classes a class can inherit from.


    Multiple Inheritance

    • Multiple Inheritance occurs when a class inherits from more than one parent.
    • Multiple inheritance  is complex but allows a more natural definition of relationships between classes or interfaces

    Single Inheritance
    • Single inheritance is simple but restrictive.

    Hope this will help you out.

    Regards,
    Phijo Mathew Philip.



    PHIJO MP
    Thursday, March 19, 2009 4:38 PM
  • In C# we can inherit as many interfaces as we like...but only one class.  So the question to me to decide whether or not to keep the interfaces defined separately or in one interface is "will there ever be a need to inherit one interface and not the other?"  If there is every even the most remote chance that you might need to inherit interface 1 and not interface 2, then there is no reason that you can't inherit from both interfaces or create a 3rd super interface that itself inherits from both.
    • Marked as answer by miridfd Sunday, March 29, 2009 8:30 AM
    Friday, March 27, 2009 10:55 PM