Matching Safeguards to Threats

A class that manages a shared list of bookings has a class invariant relating its fields. Match each safeguard the designers use to the way it keeps the object from ever reaching a state that breaks the invariant.

Match each term
A.

An object being created from starting values that already break the rule

B.

An outside reference to a mutable list changing internal data after it was stored or returned

C.

A violation going unnoticed during testing until much later, far from the faulty method

D.

Client code assigning new values to the state directly and skipping every check

E.

A rejected request leaving some fields changed and others unchanged

Defensive copying

Check-then-commit update

Private fields

Constructor validation

Representation check

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Class Invariants Questions: