Discussion Questions for Riel, Chapter 6
Definitions from Riel, p. 141:
-
Compositional mixins: The modeling of a class's properties through
the containment of property classes.
-
Delegation functions: Messages on a containing clas whose sole
purpose is to transfer the message down to a single contained object.
-
Mixins: Classes whose behaviors are inherited from a number of
propert classes.
Multiple Inheritance
-
Is containment the only way to model multiple inheritance when it's not
available, or are there other possible approaches? (Lorelei)
-
What are the usual performance penalties for using multiple inheritance?
(John)
-
Java doesn't include multiple inheritance, so how would a developer model
one of the legitimate uses of multiple inheritance without introducing
accidental complexity such as the wooden door example? (Mike L.)
-
Are there any examples where legal multiple inheritance exits but the
questions on page 135 aren't answered properly? (David D)
-
I didn't very clearly understand Heuristic 6.3. What is the disadvantage of
having a base class be actually a derived class of another base class, in
reference to Multiple Inheritance? (Gaurav)
-
Are Riel's yes/no questions alone always sufficient tests to see if
multiple inheritance is needed? (monica)
Mixins
-
Why does Riel recommend using conditional testing for compositional mixins?
( page 138). Isn't conditional testing bad? (Elijah)
-
What are some situations for programs that would work better with
compositional mixins vs. traditional mixins or vice versa? (Mike C)
-
Is the creation of a 'mixin' likely to lead to undue complexity? (Eric)
-
Could you explain mixins more thoroughly? (Mike L.)
-
Why is containment the best way to make mixins more flexible? Can you use
multiple inheritence and simply override the original function to check for
the conditional? (Lorelei)
Delegation Functions
-
What are delegation functions? (Sheng)
-
How do delegation functions work and are they only used in situations where
containment is necessary? (Mike C)
Other Questions
-
In chapter 6 Riel describes which heuristics should be satisfied in order
to use multiple inheritance, but he doesnt explicitly state the advantage
of using MI, infact he seems more against it. What are the advantages of
using MI ? (Gaurav)
-
In section 6.8 Riel suggests 'containment by reference' for the house
case. Why can?t the same solution apply to the grad student case in section
6.7 which uses 'DAG multiple inheritance'? (Chayapan)
-
can you explain the example in section 6.5 about frameworks that
incorporate multiple inheritance? (monica)
-
Are there often hard limits to the number of classes that you can use in
multiple inheritance? Does this every present a problem in practice?
(John)
-
What is "virtual" inheritance called in Java? (David D)
-
The house example in section 6.8 shows that optional containment can cause
accidental DAG multiple inheritance, but his suggested solution back in
section 5.18 does not show how to integrate the optional
component. Following the house example, how does the optional component
(heating, cooling, etc.) be separately implemented and then integrate into
the diagram? (Chayapan)
-
What is pseudo-inheritance? Is it a bad design? (Sheng)
-
on page 140, Riel says that "we cannot always eliminate one copy of base
class data". But suppose we wanted to elimate one copy of the case class
data (so that the graduate student wouldn't have two SSNs). How would we do
this? Also, how are objects 'viewed' from the point of view of Instructor
or of Student? (Elijah)
-
Is there an instance where a 'white-box' design would be a good thing? (Eric)
This document is available on the World Wide Web as
http://www.cs.grinnell.edu/~walker/courses/223.fa05/readings/riel-6.shtml