partial inheritance?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wholetthedogout
    New Member
    • Nov 2012
    • 6

    partial inheritance?

    Approaching to build the framework for safe programming.

    Can the business objects be partially inherited ,in
    .NET?

    Please help me to get an insight on.

    Regards.
    Last edited by Frinavale; Jan 24 '13, 02:17 PM.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    I think you may be confusing inheritance with "partial class"?

    I don't think I've ever heard of partial inheritance.

    What I would do is break up your inheritance structure so that it makes sense...

    So that your base objects contain only the things that you want to be inherited.

    For example if you had:
    • cars
    • vans
    • pick up trucks
    • motorcycles


    I would create a "vehicle" class that has:
    • wheels
    • engine


    I would have my "motorcycle " class inherit from the "vehicle" class so that it can add it's own custom properties to it:
    • handle bars
    • throttle
    • hand break


    I could also create an "automobile " class that inherits from "vehicle" and add custom properties to it:
    • steering wheel
    • break peddle
    • gas peddle


    Now my "car","pick up truck", and "van" classes can inherit from "automobile " and add their own unique properties to their classes. These classes will have all of the "vehicle" and "automobile " properties along with their own properties....

    And the "motorcycle " class will have have all of the "vehicle" properties but not the "automobile " properties...

    In this way the motorcycle class inherits only a "partial" amount of properties that the van class inherits simply because motorcycle inherits directly from the vehicle class while the van class inherits from the automobile class which inherits from the vehicle class.

    -Frinny
    Last edited by Frinavale; Jan 22 '13, 07:27 PM.

    Comment

    • wholetthedogout
      New Member
      • Nov 2012
      • 6

      #3
      Thank you for the reply.

      With an insight you've given, code reusability may hamper.

      Even I didn't hear of 'partial inheritance' in dotnet framework,ever.

      Actually, I wanted to get an implementation idea for what it is called as
      'partial inheritance'. To my knowledge , it can be - partial and limited or conditional access to the base class's operations and it's implementation.

      I hope this isn't an absurd thought to think over.

      Help please.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        There are scope modifiers...also called access modifiers (like private, protected, public etc.) to help restrict access to functionality in the base class.

        So, if you declare a "protected" function in your base class, any class that inherits from that class can use the function but the function will not be accessible to any other calling code.

        -Frinny
        Last edited by Frinavale; Jan 24 '13, 02:13 PM.

        Comment

        • madankarmukta
          Contributor
          • Apr 2008
          • 308

          #5
          I heard of Partial Inheritance in Python.. I didn't ever work out with Python, however.

          You may get an idea to build a framework.

          Hope this helps.

          Comment

          Working...