
Discover what clean code is, why it matters, and how to write it with practical rules and concepts, illustrated by demos and examples, plus slides and a mini ebook.
Clean code is readable and understandable, reduces cognitive load, and remains concise; avoid unintuitive names, deep nesting, and large blocks to keep maintenance easy.
Explore core clean-code pain points—from naming and structure to formatting and comments—and learn practical patterns and principles to write cleaner functions, manage conditionals, and design proper data structures.
Explore how this course structures sections around core problems, rules, and naming principles, with demos of bad and good code. Practice transforming dirty code through challenges to reinforce learning.
Acquire the basic programming experience needed for the clean code course. Use Python and JavaScript/TypeScript examples to illustrate concepts that apply to all programming languages.
Explore how strong typing affects clean code across languages like Python, TypeScript, Java, and C#. Learn that explicit types help prevent errors and may aid readability, but are not mandatory.
Understand how the course uses short, focused code examples drawn from a larger project, often not executable, and presented as standalone functions across languages.
Apply universal clean code rules across functional, object oriented, and procedural styles to ensure readable, concise functions and avoid deeply nested if statements.
Learn that clean code is readable and easy to understand, and that patterns and principles guide code to be extensible and maintainable, while distinguishing clean code from clean architecture.
Learn to write clean code through iterative refinement and refactoring. Continuously question and improve your code to stay maintainable and boost future productivity over quick, brittle solutions.
Start by focusing on naming in development, covering variables, constants, properties, functions, methods, and classes; explain why good names matter and outline naming rules with examples and demos.
Choose meaningful names for variables, functions, and classes to convey what they store or do without inspecting code. Clear naming improves readability and guides future maintenance.
Choose meaningful names for variables, constants, properties, and data containers using descriptive nouns; use verbs for functions and classes like User or RequestBody.
Explore the four main casing styles—snake_case, camelCase, PascalCase, and kebap-case—and how they map to variables, functions, and class names across Python, Java, JavaScript, and HTML.
Learn how to name variables, constants, and properties clearly by describing value types—objects, numbers, strings, and booleans—and use booleans as yes-no questions like is active or is logged in.
Master naming variables, constants, and properties by examining bad, okay, and good names for a user object, including specific choices like user, customer, and isValid or isCorrect.
Name functions and methods by describing the operation they perform or their boolean result, using clear forms such as getUser, response.send, isPaid, and getUserByEmail.
Learn how to name functions and methods clearly by contrasting bad, okay, and good names. Explore examples like process, handle, save versus saveUser, and isValid, including validation and saving intents.
Learn to name classes by describing the instantiated object, using clear, non-redundant names like user or product, avoid redundant suffixes such as DatabaseManager, and prefer instantiated types over static utilities.
Select clear, specific class names such as user, admin, customer, or sql database, and avoid vague or redundant names like uentity, objA, data, or data storage.
Recognize exceptions to naming and API rules, such as Python date time and strftime, and TypeScript getters for private properties, while applying the established guidelines.
Explore common errors and pitfalls in naming variables, functions, and classes; learn to avoid redundant details, slang, and ambiguous abbreviations, and practice consistent, distinctive names.
Demonstrate converting dirty Python code to clean code by refactoring a blog post class and moving the print function into a self-contained method.
Apply what you learned by analyzing a Python example, identify bad names across classes, variables, functions, and methods, propose better alternatives, and review the solution video to see the improvements.
This lecture teaches clean code naming by refactoring a point and rectangle example, promoting origin, width, height, and getArea, and renaming end_points to print_coordinates.
Explore how comments and code formatting influence code readability and maintainability, learn which comments are useful, apply proper formatting and language conventions, and practice with examples and a challenge.
Avoid unnecessary comments and rely on self-explanatory names to improve readability. Delete redundant, misleading, or commented-out code, and use version control to recover changes.
Explore when comments help or harm code readability, including legal information, regex explanations, API warnings, to-do notes, and documentation comments, while avoiding unnecessary comments.
Enhance code readability and understandability through vertical and horizontal formatting, following language-specific rules and general style guides for consistent indentation and spacing.
Master vertical formatting to improve readability by creating a smooth top-to-bottom flow in code, using blank lines to separate concepts and splitting large files.
Explore how language-specific rules govern function ordering and execution, contrasting JavaScript's ability to call a function before its definition with Python's need to define before use.
Learn horizontal formatting to keep code on a single readable line, using indentation and multi-line statements. Apply clear variable naming and extract long expressions into temporary variables for readability.
Fix the comments and formatting in a Python challenge file you can run, improve its clarity, and compare your solution to the instructor’s to learn clean code practices.
Refactor this file by cleaning comments, removing dividers, clarifying warnings, and tightening spacing to improve readability, maintainability, and proper error handling.
Learn to write clean functions by examining parameters, arguments, and the function body, control function length and abstraction, and split logic into smaller functions with examples and a practice challenge.
Examine what makes a function or method clean by analyzing the readability of its body, the number and order of arguments, the ease of calling, and maintaining existing functions.
Minimize function parameters to keep calls easy to understand, starting with no parameters, then one, two, or three where appropriate, and avoid more than three unless necessary.
Refactor function parameters to improve readability by moving user creation into a dedicated object or class with a safe method. Use a no-argument function for simple is-logged-in state changes.
Explore when one-argument functions are most appropriate, using a log function to illustrate swapping output mechanisms, and highlight obvious one-parameter cases like square function and the email is valid function.
Use two parameters when the order is obvious and readable, as with login or point; otherwise, refactor to two one-argument functions to reduce cognitive load.
Refactor multi-argument functions into a single argument object to improve readability and reduce order errors. Use a data container like a map or object to extract values by key.
Explore dynamic parameters in functions, showing that a six-parameter sum can be readable. Use an array or a rest operator, noting that order does not matter for readability and maintainability.
Avoid output parameters in functions, especially when unexpected, and prefer returning values; if editing a user, use a clear approach like addId, or an object-oriented pattern with user.addId.
Clean functions stay small and do one thing, using levels of abstraction to split code into focused helpers, keeping the main function lean and readable.
Learn how levels of abstraction guide function responsibilities, keeping low-level details near the function name and avoiding mixing abstraction levels in code such as emailIsValid and saveUser.
Use two rules of thumb to decide when to split a function: extract blocks that implement the same functionality into a new method, and extract code that requires more interpretation.
Demonstrate refactoring of the createUser function to separate validation, extract error handling and show error message, and delegate saving to saveUser, achieving levels of abstraction and a readable code flow.
Learn to write DRY code by splitting functions to boost reusability and avoid repeating yourself. Identify non-dry patterns like copy-paste and applying the same changes in multiple places.
Split functions to stay dry shows how extracting emailIsValid and inputIsValid, reusing showErrorMessage, reduces duplication while improving abstraction and error handling.
Balance function extraction with readability and maintainability; avoid excessive granularity that merely renames operations. Consider restructuring with a User class to centralize logic at the level of abstraction.
Keep functions pure by ensuring the same input always yields the same output, minimize side effects, and name functions to signal when side effects are expected.
Explore side effects and how to distinguish expected from unexpected ones, and learn how to refactor toward pure functions like is valid while handling logging and database connections.
Discover how unit testing and test-driven development promote clean code by breaking complex functions into small, testable units and avoiding unwanted side effects.
Overview techniques and rules for cleaning up controlled structures to avoid deep nesting. Apply factory functions, polymorphism, positive checks, and smart error use to refine naming and guard concepts.
Learn to use guards to fail fast, invert problematic if checks, and reduce nesting for cleaner, more readable code.
Apply guard clauses to reduce nesting and implement fast-fail logic in a JavaScript transaction loop, using continue and return to handle non-open statuses.
Improve readability by extracting control structures into functions and preferring positive checks, turning complex if statements into concise helpers like isEmpty and showErrorMessage.
Extracts per-transaction logic from processTransactions by introducing a dedicated processTransaction function, preserving guard and loop structure, and improving readability and abstraction while maintaining transaction checks.
Learn to simplify complex transaction logic by extracting dedicated functions for payments and refunds, and improve the readability of processTransaction with focused checks and clearer abstractions.
Inverts the checking logic by first identifying the transaction method (credit card, PayPal, or plan) and then processing payments or refunds in specialized functions.
Learn to use errors and error handling to replace excessive if statements by throwing and handling real error objects with built-in mechanisms and custom error classes.
Refactor error handling by replacing in-place logs with guard checks that throw descriptive errors in processTransaction, then handle per-transaction errors with a try-catch inside the loop.
Refactor your code by extracting validation into dedicated functions like validateTransactions and validateTransaction, slim down processTransactions, and ensure errors bubble up for clean, readable code.
Apply the single-responsibility rule to error handling with a focused try-catch block. Move validation and processing into dedicated functions and use method-based dispatch to improve readability.
Explore how factory functions and polymorphism create a single, reusable transaction processor that returns a map of payment and refund handlers.
Use default parameter values to ensure showErrorMessage always has an item, eliminating if checks and improving readability by using console.log with a default empty map.
Explore polymorphism as an alternative to duplicate if checks and learn to split code into focused functions and data, util, and processing folders for a lean, clean codebase.
Explore the distinction between real objects and data structures, and apply core object oriented principles, solid, Law of Demeter, and polymorphism to keep classes clean.
Learn core principles for writing clean, readable code applicable beyond object oriented programming, focusing on maintainability and clarity, not a deep dive into object oriented patterns and principles.
Differentiate real objects from data containers by showing how real objects hide internals behind a public api and abstractions, while data containers expose data publicly with minimal methods.
Distinguish between using a class as a real object and as a data container to avoid mixing concepts, and encapsulate connection logic so changes stay inside the class.
This lecture demonstrates polymorphism with classes, introducing a base delivery class and specialized express, insured, and standard deliveries, using a factory to instantiate the right type and remove if checks.
Learn how to write clean, small classes focused on a single responsibility, split large responsibilities into multiple classes, and keep product, orders, and customer concerns distinct.
Learn how cohesion measures how well a class's methods use its properties, aiming for high cohesion rather than maximum, and how splitting into smaller classes improves cohesion.
Master the law of demeter and the tell, not ask. Avoid drilling into internals and instead call methods that operate on objects passed as parameters.
Explore the solid principles for object-oriented design, including single responsibility, open-closed, Liskov substitution, interface segregation, and dependency inversion. Learn how these rules make classes well-written, extensible, and maintainable.
Apply the single-responsibility principle in clean code to keep classes small and focused, so changes occur for one reason, separating data generation from PDF creation.
Explore the open-closed principle in clean code, design extensible printers with interfaces and base classes, keeping APIs closed to modification while enabling feature extension.
Apply the Liskov Substitution Principle: replace a base class with subclass instances without changing behavior, as with birds and eagles, but penguins reveal the need for proper base-class modeling.
Apply the interface segregation principle by prioritizing client-specific interfaces over one general interface. Show how sql database and in-memory database expose only relevant methods, like store data.
Apply the dependency inversion principle by depending on abstractions, not concretions; have the app accept a database interface and provide a concrete database, enabling inversion, maintainability, and extensibility.
Explore the core rules of clean code, focusing on descriptive naming and readable functions. Apply formatting, comments, and SOLID principles to keep code maintainable and human-friendly.
Write clean code focused on readability and understandability, using meaningful names, slim, concise and clean functions, clear control flow, and no nested if statements, while applying conventions like PEP 8.
Discover next steps after clean code, including clean architecture, patterns to organize code for extensibility and maintainability, separating database access logic from view logic, and test-driven development to boost readability.
Apply what you learned by building demo projects and using it in your day-to-day work to reinforce a solid foundation in clean code.
As a developer, you should be able to write code which works - of course!
A lot of developers write bad code nonetheless - even though the code works. Because "working code" is not the same as "clean code"!
This course teaches you how to write clean code - code that is easy to read and understand by humans, not just computers!
In this course, you'll learn what exactly clean code is and, more importantly, how you can write clean code. Because if your code is written in a clean way, it's easier to read and understand and therefore easier to maintain.
Because it's NOT just the computer who needs to understand your code - your colleagues and your future self needs to be able to understand it as well!
In this course, we'll dive into all the main "pain points" related to clean code (or bad code - depending on how you look at it) and you will not just learn what makes up bad code but of course also how to turn it into clean code.
Specifically, you will learn about:
Naming "things" (variables, properties, classes, functions, ...) properly and in a clean way
Common pitfalls and mistakes you should avoid when naming things
Comments and that most of them are bad
Good comments you might consider adding to your code
Code formatting - both horizontal and vertical formatting
Functions and how to limit the number of function parameters
How to write clean functions by focusing on "one thing"
How levels of abstraction help you split functions and keep them small
How to write DRY functions and avoid unexpected side effects
Avoiding deeply nested control structures with guards and by extracting functionality into functions
Errors and error handling as a replacement for if-statements
Objects & data containers/ data structures and why that differentiation could matter
Cohesion and how to write good (small!) classes
The Law of Demeter and why it matters for clean code
What the SOLID principles are and why they matter when it comes to writing clean code
Much more!
This course is a compilation of common patterns, best practices, principles and rules related to writing clean code.
In this course, you'll learn about a broad variety of concepts, rules, ideas, thoughts and principles and by the end of course, you'll have a good idea of what to keep in mind when it comes to writing clean code.
This is not a design patterns or general patterns course though - we will entirely focus on patterns, rules and concepts that help with writing clean code specifically.
All these concepts and rules are backed up by examples, code snippets and demos. And to ensure that you get the most out of this course, and you don't just learn a bunch of theory which you forget soon after, there also are plenty of challenges for you to apply what you learned!
This course uses Python, JavaScript and TypeScript for code examples but you don't need to know these languages to follow along and get a lot out of the course. In addition, the course does not focus on a specific programming style or paradigm (like functional programming, object-oriented programming etc) but instead covers general concepts and techniques which will always apply.
What are the course prerequisites?
Basic programming knowledge (no matter which language) is required!
You don't need to know any specific programming language or programming paradigm to follow along
NO prior experience with writing clean code is required