CSE Roadmap

Core tier · about 3 hours · 6 parts

Part 1 of 6 · 1 min read

Why this page comes second in Level 5

In this module you will

  • Apply the five rules that make a Java class immutable.
  • Model money, time and similar values as value objects.
  • Make defensive copies so callers cannot reach inside an object.
  • Write "with" methods that return a changed copy.
  • Explain how immutability helps failure handling and threads.

Level 1, module 2 introduced immutable values in a few lines. This page treats them as a design tool. Many bugs in a booking or banking design come from a value that changed while another part of the code was holding it. Immutable values remove that whole class of bug, and they make the thread-safety module (module 3) much shorter. The source is mainly "Effective Java" (EJ) Items 17 and 50, with "Clean Code" for naming. Code was compiled and run before it was written here. Numbers marked "made up" only show the idea.