Skip to main content
Object Calisthenics 60 XP · 6 min

Keep All Entities Small

No class over 50 lines, no package over 10 files — small classes fit on one screen, force focus, and naturally organize into cohesive packages.

Showing
Ad (728×90)

Why this matters

A class that doesn't fit on one screen is a class with too many secrets. You cannot hold its entire behavior in your head at once, which means you cannot reason about it, test it, or change it with confidence. The 50-line limit is not arbitrary — it is the forcing function that makes you extract responsibilities before they grow into unmanageable masses. The same logic applies to packages: 10 files per package means each package has a clear, singular purpose that you can describe in one sentence.

Code Challenge

Study the messy code, try to refactor it, then reveal the clean version.

Key takeaway

A class that doesn't fit on one screen is a class that has too many secrets. Break it up until everything is visible — 50 lines per class, 10 files per package forces the discipline that makes code navigable and changeable.

Done with this lesson?

Mark it complete to earn XP and track your progress.