Computer Science 223 Discussion Questions

Riel, Sections 5.1-5.6

Discussion Questions submitted for Sections 5.1-5.6 of Riel

Inheritance, Specialization, Generalization, and Containment

One-phrase Definitions:

Inheritance: or public inheritance: a subclass becomes a subtype of a superclass or base class
Specialization: one item is a special case of another
Generalization: identification of one or more common elements (data, operations) among several classes
Containment: an object or class is a component of another.

  1. What are the differences between generalization and specialization? --Khong
  2. What are the advantages of inheritance over containment? (Sam Vanderhyden)
  3. Can you clarify the difference between inheritance and containment relationships?
  4. An real world example of Heuristic 5.1 will nice. - George
  5. Can you give a less abstract example of heutistic 5.1? Anthony
  6. Can you better distinguish how inheritance can be both a generalization and a specialization? - Jim Finnessy
  7. Is it really true that in all cases base classes should have no knowledge of derived classes? Is reusability the major reason for this? Patrick Dowd
  8. Can you clarify the ambiguity among superclasses and subclasses? - Jim Finnessy
  9. It seems that a white-box design and heuristic 5.2 contradict each other. Could you please explain the difference between those? --Hisako
  10. Does heuristic stating that inheritance should only be used to model a specialization hierarchy mean that you should avoid generalization-style inheritance? (-Nick W.)
Public, Protected, and Private Data
  1. What properties of public and private access areas does the protected access area contain? ~yasir.
  2. Can you discuss private/public data a bit more? -Kensler
  3. Please axplain the concept of protected data and methods of a class? Anthony
  4. Could you explain in a bit more detail the difference between public, private, and protected data, and when each is appropriate?
  5. Why does heuristic 5.3 limit its scope to only base classes? i.e. why should data ever be protected or public? Steve F
  6. Is it really never ever good to have protected data? Dessislava Dimova
  7. I am still confused about why we should use private data with protected accessibility instead of just protected data in a base class. Could you explain more on this? (Raz Magar)
Width and Depth of Inheritance Hierarchies
  1. Why have heuristic 5.4 if it is immediately qualified by 5.5? Why not only have 5.5? -Peter Likarish
  2. What are the merits and demerits of Heuristic 5.4? - George
  3. Can you give more detail on what is meant by deep in Heur. 5.4? -Kensler
  4. Why is it better to have deep inheritance hierarchies? Don't they just contribute to overall complexity? (Sam Vanderhyden)
  5. In what kind of design would generalization hierarchy be applicable? (Raz Magar)
  6. Heuristic 5.4: why is this good? Why can't we have a class with all the abstractions? - Elias Vafiadis
  7. Could you explain the distinction in different types of inheritance using C++ illustrated on pg. 87? -Peter Likarish
  8. could you differentiate between deep hierarchies and specialization hierarchies. taha
  9. I found the comment on the bottom of page 84, about how a graphical tool could invalidate heuristic 5.5, particularly striking. Isn't it true that graphical computer-generated views could invalidate many of the heuristics we have seen concerning boundaries designers should operate in? Todd
Public, Protected, and Private Inheritance in C++
  1. Riel advises not to use private and protected inheritance in C++. Is it still good idea to use these implemented relationships for containment purposes? Dessislava Dimova
  2. Can you clarify the difference between public inheritance and protected inheritance?
  3. could you give examples of the correct use of protected, private and public inheritance. taha
  4. Why does C++ allow you to use private or protected inheritance? Does Java as well? Steve F
  5. If protected data should not be used, then why does the author consider languages with no provision for protected data inferior to those that have it? Patrick Dowd
Method Overriding
  1. To what is Riel referring when on p. 79 he states that "most object-oriented languages support the calling of the base class method from an overriding derived method"? How exactly does this work? (-Nick W.)
  2. What exactly is the overriding method? The user can add a specialization relationship that is not behaviorally compatible to the superclass; can the user completely change or delete a message of the superclass? - Elias Vafiadis
  3. Are there any disadvantages of allowing overriding? ~yasir.
Miscellaneous Problems
  1. the C++ inheritance setup seems complex, is this something that needs to be known? ,li> Could we get more explanation of the types of inheritance in Java and C++? Todd
  2. What are the differences between public section of a class and public interface of a class? Why does one want to separate accessibility for each of those? --Hisako
  3. How can we illustrate the differences between a black-box design and a white-box design? --Khong
  4. How should you handle cases where a class can logically inherit from more than one base class?
  5. what is the usefulness limit to abstract classes as base classes?


This document is available on the World Wide Web as

http://www.walker.cs.grinnell.edu/courses/223.sp02/read-riel-5a.html

created March 12, 2002
last revised April 7, 2002
Valid HTML 3.2!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.