the question is self explanatory, I just want to know when to use the inclusion and when to use inheritance, and which one serves for re-usability.
in other words, which one meets the Object Oriented programming principles the most?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
In general I would agree to favor composition over inheritance. You can think of composition as a "has-a" relationship and inheritance as an "is-a" relationship. Composition helps manage complexity by keeping each class separate and only aggregating what you need.
One drawback to composition is that you may find yourself having to write a number of proxy "forwarding" methods for your composed classes.
I find a good rule of thumb is that if a class really is a type of the base class and needs most or all of the base class functionality exposed, these are good reasons to consider using inheritance.
I think you might be confusing the terms. Inclusion is actually a form of inheritance, it basically says that if you a type T, then subtype T1 and subtype T2 can be sent the same messages.
Perhaps you wanted to know the difference between object aggregation/composition and inheritance? If so, then in general favor aggregation and composition over inheritance asit often prevents restructuring base classes if requirements change.
If you want to know more, then I recommend reading the GoF (Gang of Four)'s book Design Patterns: Elements of Reusable Design, or try Head First Design Patterns which is a bit easier to read and understand.