Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

15
  • 1
    Does this answer your question? Why should I prefer composition over inheritance? Commented Feb 14, 2022 at 15:31
  • 4
    @gnat not really, because I don't know what those "very painful problems" can be in my example and also what does he mean by model domain :) Commented Feb 14, 2022 at 15:34
  • 58
    What happens when a student graduates and becomes a teacher? What about a student who teaches a seminar? Commented Feb 14, 2022 at 15:47
  • 7
    to model is the verb in that sentence, it's not a model domain. In much the same way that a painting of a pipe is not a pipe, a class named Person is not a person. Commented Feb 14, 2022 at 16:04
  • 5
    @JörgWMittag - you delete the student record, and create a teacher record? Or keep both, with a reference? There are plenty of solutions for these imaginary problems. Commented Feb 15, 2022 at 0:33