Writing Clean Code: Naming, Functions & Structure
This course teaches you the practical principles behind naming, functions, and code structure that separate professional code from messy code. You will refactor a real multi-file codebase and produce clean, readable, maintainable code by the end.
Course Content
6 modules ยท 30 lessonsWhy Naming Matters
After this module, students can choose clear, intention-revealing names for variables, functions, and classes without relying on abbreviations or vague terms.
How to name variables so your code explains itself
intention-revealing names, avoiding abbreviations, meaningful context, variable scope naming, boolean naming conventions
How to name functions clearly in any language
verb-noun function naming, single responsibility signals, predicate functions, factory vs action names, naming consistency across codebase
Class and type naming conventions that make architecture clear
noun-based class names, avoiding manager and helper suffixes, design pattern naming, interface and abstract class naming, domain language alignment
Common bad naming patterns and how to fix them
magic numbers, Hungarian notation, single-letter names, noise words, misleading names, naming antipatterns
Naming conventions by language: JavaScript, Python, and Java
camelCase, snake_case, PascalCase, SCREAMING_SNAKE_CASE, language-specific conventions, linter enforcement, team consistency
Writing Functions That Do One Thing
After this module, students can identify, extract, and write functions that have a single responsibility and a predictable size.
What does single responsibility mean for a function
single responsibility principle, function cohesion, reasons to change, side effects, functional purity basics
How long should a function be โ the right answer
function length guidelines, indentation depth, scroll-free functions, line count heuristics, cognitive complexity
How many parameters should a function take
parameter count limits, parameter objects, niladic and monadic functions, flag arguments antipattern, builder pattern for arguments
Side effects in functions and why they cause bugs
pure functions, side effects definition, hidden side effects, referential transparency, function predictability, testing implications
How to extract functions from long methods without breaking code
extract method refactoring, identifying extraction candidates, return value handling, preserving behavior, step-by-step extraction process
Code Structure and Organization
After this module, students can organize files, folders, and modules so that any developer can navigate a codebase without a guide.
How to structure a project folder so it explains itself
feature-based vs layer-based structure, colocation, barrel files, folder naming, project root organization
What belongs in a module and what to export
module cohesion, export discipline, public vs private interface, encapsulation in modules, barrel exports
How to organize code within a single file
file-level ordering, imports first, constants second, class ordering, newspaper metaphor, related code colocation
How to avoid circular dependencies between modules
circular dependency definition, dependency direction, dependency inversion, interfaces to break cycles, module dependency graph
How to separate business logic from infrastructure code
hexagonal architecture basics, business logic isolation, infrastructure dependencies, dependency injection, testability through separation
Comments and Documentation Done Right
After this module, students can write comments and documentation that add value instead of restating the obvious.
When to write comments and when to delete them
code vs comments, noise comments, redundant comments, comment rot, intention over implementation
How to write JSDoc and docstrings that developers actually read
JSDoc syntax, Python docstrings, parameter documentation, return types, example documentation, when to skip docstrings
How to write a README that developers immediately understand
README structure, quick start section, prerequisite documentation, environment setup, contribution guide basics
How to write clear TODO comments without creating tech debt traps
TODO conventions, ticket-linked TODOs, FIXME vs TODO vs HACK, comment expiry, automated TODO tracking
Inline comments vs commit messages: what goes where
commit message anatomy, conventional commits, what belongs in commits vs code, git blame usage, linking commits to issues
Refactoring: Making Existing Code Readable
After this module, students can apply systematic refactoring techniques to improve real codebases without introducing bugs.
What is refactoring and what it is not
refactoring definition, behavior preservation, refactoring vs rewriting, refactoring vs optimization, safe refactoring steps
Replace conditionals with early returns to flatten code
early return pattern, guard clauses, else removal, arrow anti-pattern, nested conditional flattening
Replace magic values with named constants and enums
replacing magic numbers, replacing magic strings, enums in JavaScript and Python, const objects as enums, string union types
How to remove duplicate code with the DRY principle
DRY principle, code duplication types, extracting common logic, when not to DRY, rule of three, abstraction traps
How to refactor code safely using small steps and tests
test-first refactoring, characterization tests, boy scout rule, incremental refactoring, feature flags during refactor
Clean Code in Real Projects
After this module, students can apply all clean code principles together in a real project context and establish team-level standards.
How to set up a linter to enforce clean code automatically
ESLint setup, Prettier configuration, lint rules for naming and complexity, pre-commit hooks with Husky, CI lint enforcement
How to conduct a clean code review that actually improves code
code review principles, asking questions vs mandating, naming feedback, function size feedback, automated vs manual review
How to balance clean code with deadlines in a real team
technical debt management, good enough vs perfect, incremental improvement, boy scout rule in practice, clean code ROI argument
How to apply clean code principles in TypeScript specifically
TypeScript types as documentation, interface naming, type alias vs interface, strict mode, discriminated unions, avoiding any
How to create a team clean code standard document
CONTRIBUTING.md structure, naming conventions document, function standards, review checklist, onboarding clean code fast
