honeytrap.devexercisesliskov-substitution.javaSettings
Description

3. Liskov Substitution

MediumSOLID1 hidden requirement

Relying only on what an interface promises, not on what today’s implementation happens to do

Layout sizes a box and reports the area it ends up with. It works the answer out from the numbers it was given rather than asking the box.

For a rectangle that is always right, so the tests pass.

Box promises that setWidth and setHeight are honoured and that area() tells the truth. It does not promise the two are independent. Rewrite resizeTo so it relies on nothing beyond that.

Read the article →

Run compiles every file and runs Tests.java — the tests you can read.

Submit runs those again, then applies 1 requirement you have not seen, one at a time.

Your code is never edited. Each requirement is added to the project as it stands. If the design is right, nothing you wrote has to change.

  • Ctrl/⌘ + Enter runs the tests