W3docs

Clean Code

Learn how to write readable, understandable and therefore maintainable code - step by step, in an example-driven way

Start course

As a developer, you should be able to write code which works - of course!

Unfortunately, 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 which 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.

Course content

Section 1Getting Started

  • Welcome to the Course!
    2:27
  • What is "Clean Code"?
    5:57
  • Clean Code - Key Pain Points & How To Write Clean Code
    3:31
  • How Is This Course Structured?
    1:22
  • Course Prerequisites
    3:16
  • Clean Code & Strongly Typed Languages
    2:31
  • About The Course Code Examples
    2:04
  • Functional, OOP, Procedural: The Course Concepts Always Apply!
    1:29
  • Clean Code, Principles & Patterns & Clean Architecture
    3:17
  • Clean Code vs Quick Code
    5:01
  • Module & Course Resources
    1:00

Section 2Naming - Assigning Names to Variables, Functions, Classes & More

  • Module IntroductionPremium
    1:01
  • Why Good Names MatterPremium
    3:23
  • Choosing Good NamesPremium
    4:03
  • Casing Conventions & Programming LanguagesPremium
    3:07
  • Naming Variables & Properties - TheoryPremium
    3:48
  • Naming Variables & Properties - ExamplesPremium
    4:44
  • Naming Functions & Methods - TheoryPremium
    2:36
  • Naming Functions & Methods - ExamplesPremium
    3:10
  • Naming Classes - TheoryPremium
    1:56
  • Naming Classes - ExamplesPremium
    2:34
  • Exceptions You Should Be Aware OfPremium
    6:24
  • Common Errors & PitfallsPremium
    7:50
  • Demo Time!Premium
    10:29
  • Your Challenge - ProblemPremium
    1:11
  • Your Challenge - SolutionPremium
    10:01
  • Module ResourcesPremium
    1:00

Section 3Code Structure, Comments & Formatting

  • Module IntroductionPremium
    1:06
  • Bad CommentsPremium
    3:52
  • Good CommentsPremium
    3:50
  • What is "Code Formatting" Really About?Premium
    2:26
  • Vertical FormattingPremium
    8:03
  • Formatting: Language-specific ConsiderationsPremium
    2:03
  • Horizontal FormattingPremium
    3:36
  • Your Challenge - ProblemPremium
    1:01
  • Your Challenge - SolutionPremium
    6:19
  • Module ResourcesPremium
    1:00

Section 4Functions & Methods

  • Module IntroductionPremium
    1:12
  • Analyzing Key Function PartsPremium
    1:38
  • Keep The Number Of Parameters Low!Premium
    6:38
  • Refactoring Function Parameters - Ideas & ConceptsPremium
    3:43
  • When One Parameter Is Just RightPremium
    2:12
  • Two Parameters & When To RefactorPremium
    4:07
  • Dealing With Too Many ValuesPremium
    4:26
  • Functions With A Dynamic Number Of ParametersPremium
    2:41
  • Beware Of "Output Parameters"Premium
    4:19
  • Functions Should Do One Thing!Premium
    9:51
  • Why "Levels of Abstraction" MatterPremium
    6:11
  • When Should You Split?Premium
    2:51
  • Demo & ChallengePremium
    13:09
  • Stay DRY - Don't Repeat YourselfPremium
    2:03
  • Splitting Functions To Stay DRYPremium
    5:41
  • Don't Overdo It - Avoid Useless ExtractionsPremium
    6:51
  • Understanding & Avoiding (Unexpected) Side EffectsPremium
    12:01
  • Side Effects - A ChallengePremium
    9:21
  • Why Unit Tests Matter & Help A Lot!Premium
    6:15
  • Module ResourcesPremium
    1:00

Section 5Control Structures & Errors

  • Module IntroductionPremium
    2:52
  • Useful Concepts - An OverviewPremium
    1:22
  • Introducing "Guards"Premium
    2:53
  • Guards In ActionPremium
    6:33
  • Extracting Control Structures & Preferring Positive PhrasingPremium
    3:17
  • Extracting Control Structures Into FunctionsPremium
    4:03
  • Writing Clean Functions With Control StructuresPremium
    7:32
  • Inverting Conditional LogicPremium
    8:07
  • Embrace Errors & Error HandlingPremium
    6:57
  • Creating More Error GuardsPremium
    4:27
  • Extracting Validation CodePremium
    4:10
  • Error Handling Is One Thing!Premium
    3:35
  • Using Factory Functions & PolymorphismPremium
    8:56
  • Working with Default ParametersPremium
    1:14
  • Avoid Magic Numbers & StringsPremium
    1:00
  • Module SummaryPremium
    3:37
  • Module ResourcesPremium
    1:00

Section 6Objects, Classes & Data Containers / Structures

  • Module IntroductionPremium
    1:42
  • Important: This is NOT an OOP or "Patterns & Principles" Course!Premium
    2:14
  • Objects vs Data Containers / Data StructuresPremium
    4:10
  • Why The Differentiation MattersPremium
    3:57
  • Classes & PolymorphismPremium
    12:54
  • Classes Should Be Small!Premium
    6:20
  • Understanding "Cohesion"Premium
    4:49
  • The "Law Of Demeter" And Why You Should "Tell, Not Ask"Premium
    11:40
  • The SOLID PrinciplesPremium
    2:05
  • The Single-Responsibility-Principle (SRP) & Why It MattersPremium
    7:04
  • The Open-Closed Principle (OCP) & Why It MattersPremium
    5:43
  • The Liskov Substitution PrinciplePremium
    5:56
  • The Interface Segregation PrinciplePremium
    4:18
  • The Dependency Inversion PrinciplePremium
    7:00
  • Module ResourcesPremium
    1:00

Section 7Summary & Checklist

  • Concepts Summary & ChecklistPremium
    9:05

Section 8Course Roundup

  • Staying Clean!Premium
    2:56
  • Possible Next StepsPremium
    2:43
  • Thanks & Goodbye!Premium
    1:14
  • Bonus!Premium
    1:00

Course instructor

Photo of Maximilian Schwarzmüller

Maximilian Schwarzmüller

As a self-taught professional I really know the hard parts and the difficult topics when learning new or improving on already-known languages. This background and experience enable me to focus on the most relevant key concepts and topics. My track record of many 5-star rated courses, more than 1,000,000 students worldwide as well as a successful YouTube channel is the best proof for that.

The most rewarding experience for me is to see how people find new, better jobs, build awesome web applications, work on amazing projects or simply enjoy their hobby with the help of my content. That's why, together with Manuel Lorenz, I founded Academind to offer the best possible learning experience and to share the pleasure of learning with our students.