Skip to main content

Sign in to CleanKata

Track your progress, earn XP, and unlock every lesson.

By signing in you agree to our Terms of Use and Privacy Policy.

Clean Code70 XP7 min

SerialDate: Diagnosis

A case study in reading legacy code critically — find the smells before touching anything.

Read Before You Touch

The first step with any legacy class is diagnosis. Read the code top to bottom. List every smell. Don't fix anything yet — understanding the full picture before the first edit prevents cascading breakage. The SerialDate class from the JCommon library is a famous case study from Clean Code chapter 16.

Common SerialDate Smells

Mixed abstraction levels: static utility methods alongside abstract instance methods. Primitive obsession: months stored as plain integers instead of an enum. Misleading name: "Serial" is an implementation detail, not the domain concept. Overly large class: one class doing date arithmetic, parsing, formatting, and serialisation.

Code Challenge

Name each smell before looking at the diagnosed version.

💡Key takeaway

Diagnosis is a discipline. Write down every smell you observe before changing a single line — the list becomes your refactoring plan.

🔧 Some exercises may still have errors. If something seems wrong, use the Feedback button (bottom-right of the page) to report it — it helps us fix it fast.

Hint: Diagnosis before surgery. List every smell you find before writing a single line of new code.

✗ Your version

SerialDate: Diagnosis — CleanKata — CleanKata