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 Code

Write readable, maintainable code that other developers will love.

47 lessons

Class Organization

Classes should be small, focused, and have a single reason to change.

Earn +70 XP7 min

The Clean Code Mindset

Why clean code is a professional discipline — and how dirty code silently destroys teams and companies.

Earn +50 XP8 min

Clean Concurrency Strategies

Write concurrent code that is correct, readable, and free of subtle data-race bugs.

Earn +70 XP7 min

Clean Error Handling

Error handling is a separate concern — keep it isolated so your main algorithm stays readable.

Earn +60 XP6 min

Clean Unit Testing

Tests are first-class code — dirty tests become as costly to maintain as production code.

Earn +60 XP6 min

Comment Heuristics

Identify and eliminate bad comments; write the rare good one with precision.

Earn +50 XP5 min

Concurrency: Client-Server Model

Structure client-server concurrent systems to isolate shared state and avoid subtle threading bugs.

Earn +70 XP7 min

Concurrency: Deadlock & Starvation

Recognize and eliminate the four conditions that produce deadlock in concurrent systems.

Earn +70 XP7 min

Deadlock: The 4 Conditions

A deadlock requires all four Coffman conditions simultaneously — break any one and deadlock becomes impossible.

Earn +70 XP7 min

Concurrency: Jiggle Testing

Race conditions hide in timing gaps — shaking execution order with random yields and multi-platform runs forces them into the open.

Earn +70 XP7 min

Don't Repeat Yourself

🔒

Every piece of knowledge must have a single, authoritative representation in the codebase.

Requires 25 XP to unlock7 min

Duplication & Abstraction

🔒

Recognize hidden duplication and choose the right abstraction to eliminate it.

Requires 50 XP to unlock6 min

The 5S Philosophy in Code

🔒

How the Toyota 5S manufacturing philosophy maps to professional software craftsmanship — naming, organization, cleaning, standardization, and discipline.

Requires 75 XP to unlock6 min

Framework Analysis

🔒

Understand what a framework does before using it — read the source, not just the docs.

Requires 100 XP to unlock6 min

Function Heuristics

🔒

Apply the F1–F4 heuristics to keep functions minimal, focused, and side-effect-free.

Requires 125 XP to unlock5 min

Abstraction Levels & Dependencies

🔒

Keep high-level policy separate from low-level detail, and ensure base classes never depend on derived classes.

Requires 150 XP to unlock6 min

Coherence & Clarity

🔒

Apply the same pattern everywhere, avoid conceptual clutter, and never couple unrelated concerns.

Requires 175 XP to unlock6 min

Conventions & Magic Numbers

🔒

Follow team coding standards religiously and replace every magic literal with a named constant.

Requires 200 XP to unlock5 min

Environment & Truth

🔒

Build systems that compile in one step, run all tests in one step, and never lie through suppressed warnings.

Requires 225 XP to unlock6 min

Expressiveness & Algorithms

🔒

Use explanatory variables, precise names, and a deep understanding of the algorithm to make code speak for itself.

Requires 250 XP to unlock6 min

Feature Envy

🔒

A method that spends most of its time reading another class's data belongs in that class.

Requires 275 XP to unlock5 min

Logic & Polymorphism

🔒

Make all dependencies explicit, and replace if/switch chains with polymorphic dispatch.

Requires 300 XP to unlock6 min

Noise & Organization

🔒

Eliminate excessive information, dead code, and vertical distance to keep every file easy to scan.

Requires 325 XP to unlock6 min

Placement & Statics

🔒

Put every function in the class most interested in it, and keep static methods truly stateless utilities.

Requires 350 XP to unlock6 min

Selectors & Intent

🔒

Boolean and enum selector arguments obscure intent — split them into focused, well-named functions.

Requires 375 XP to unlock6 min

Heuristics Catalog Overview

🔒

A curated catalog of code smells and refactoring heuristics drawn from Clean Code chapter 17.

Requires 400 XP to unlock8 min

G16: The Obscured Intent

🔒

Code that tries to be clever is code that fails to communicate — density and brevity at the cost of clarity are not virtues.

Requires 425 XP to unlock5 min

G21: Understanding the Algorithm

🔒

Tests passing is not the same as understanding — clean code requires you to fully grasp why the algorithm works before you commit it.

Requires 450 XP to unlock5 min

G22: Logical to Physical Dependencies

🔒

Never let a module silently assume a value from another — make every dependency explicit and declared in code.

Requires 475 XP to unlock6 min

Java-Specific Heuristics (J1–J3)

🔒

Three Java-focused heuristics: avoid wildcard imports, never inherit constants, and prefer enums over integer constants.

Requires 500 XP to unlock5 min

Legacy Code Refactoring

🔒

Safely transform tangled legacy code by adding tests first and refactoring in small steps.

Requires 525 XP to unlock7 min

The Art of Naming

🔒

Write names that reveal intent, avoid confusion, and make code searchable.

Requires 550 XP to unlock5 min

Naming Heuristics

🔒

Apply the N1–N7 heuristics to write names that are accurate, unambiguous, and searchable.

Requires 575 XP to unlock6 min

The Necessary Evil of Comments

🔒

Code is the only source of truth — comments lie as the code evolves.

Requires 600 XP to unlock5 min

Objects vs Data Structures

🔒

Objects hide data behind behavior. Structures expose data. Mixing both creates hybrids nobody wants.

Requires 625 XP to unlock6 min

Programmer Ethics & Attitude

🔒

Quality is a professional responsibility — not something you deliver when time allows, but the non-negotiable minimum of your craft.

Requires 650 XP to unlock6 min

Pure Functions

🔒

A pure function always returns the same output for the same input and changes nothing outside itself.

Requires 675 XP to unlock7 min

Responsibility Selectors

🔒

Use the Single Responsibility heuristics to detect and split overloaded classes and modules.

Requires 700 XP to unlock6 min

SerialDate: Cleanup & Transformation

🔒

Apply successive refinement to the SerialDate class — test, rename, extract, and simplify.

Requires 725 XP to unlock7 min

SerialDate: Diagnosis

🔒

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

Requires 750 XP to unlock7 min

The 4 Rules of Simple Design

🔒

Kent Beck's four rules, in priority order, for a design that is always ready to evolve.

Requires 775 XP to unlock6 min

Small Functions

🔒

Functions should do one thing, do it well, and do it only.

Requires 800 XP to unlock6 min

Style & Format as Communication

🔒

Code formatting is a communication act — structure files so any developer can navigate them in seconds.

Requires 825 XP to unlock5 min

Successive Refinement

🔒

Start with working code, then refactor iteratively — never write clean code in one pass.

Requires 850 XP to unlock6 min

System Boundaries

🔒

Third-party code belongs at the edge — wrap it so it never pollutes your business logic.

Requires 875 XP to unlock6 min

The Three Laws of TDD

🔒

Master the red-green-refactor micro-cycle: write a failing test first, then only the code needed to pass it.

Requires 900 XP to unlock6 min

Testing Heuristics

🔒

Apply the T1–T9 heuristics to write complete, meaningful, and maintainable test suites.

Requires 925 XP to unlock6 min