I am in the process of making a PHP web application. I have a situation that I believe would foster a good time for nested inheritance. Anyway, here is my situation:
public class RecurringWeeklyEvent extends RecurringEvent { }
public class RecurringEvent extends Event { }
It does not seem to me that this would be a bad design practice; however, I am not an advanced Object-Oriented programmer by any means. With that said, before I venture off using this kind of code in my application, I would like to know if this is a good or bad practice from more experienced/qualified programmers.
NOTE: I changed the title from multiple inheritance to nested inheritance after being corrected of using the wrong term.
Thanks
Steve
To quote David West:
So what you’re doing seems fine, so long as you’re adding behaviour to your derived classes (i.e., inheritance is not a tool for adding in extra members), and (preferably) not altering the defined behaviour of the bases classes.
Elaboration
What duffymo says is correct. I want to add my 2p from my interpretation of what David West says in his book.
Overriding methods should be avoided where possible. Changing the behaviour of a method in a child class could lead to confusion for implementers.
(I’m still getting my head around OOP and Object Thinking.)