se-edu / se-book

:book: Online Book: Software Engineering for Self-Directed Learners
https://se-edu.github.io/se-book/
42 stars 32 forks source link

Design issue in association class section #45

Open rmmilewi opened 6 years ago

rmmilewi commented 6 years ago

Hi there! I was looking through your online book, and I wanted to point out that there's a design issue in the section on inheritance. From the text:

However, the two classes cannot be simply replaced with a more general class Person because of the need to distinguish between Man and Woman for the ‘marriage’ association. A solution is to add the Person class as a super class and let Man and Woman inherit from Person.

Given that same-sex marriage is legal in most of the developed world, distinguishing between Man and Woman in the class Marriage makes the implementation fragile to changes in requirements. A more robust solution is to use the type Person.

This is actually a really good example of how untested assumptions that we as software engineers make can come back to haunt us later. This could be a good object lesson on the need for requirements analysis.

damithc commented 6 years ago

Good point @rmmilewi Thanks for raising it. 👍 Will incorporate it in the next revision.