Skip to content

Design issue in association class section #45

Description

@rmmilewi

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions