What is “Clean Code”?
It’s not about
whether code works
A vast majority of time
is spent reading and
understanding code.
What Is Clean Code?
Should be readable and Should reduce cognitive Should be concise and
meaningful load “to the point”
Should avoid unintuitive Should follow common
Should be fun to write
names, complex nesting best practices and
and to maintain
and big code blocks patterns
Clean Code Is Easy
To Understand –
Dirty Code Is Not
Write A Good Story!
Your code is like an essay
You are the author
Write it such that it’s fun and easy to read
and understand!
Module Content
Course Content, Structure & Prerequisites
Clean Code vs Patterns & Principles
How To Write Clean Code
Key Pain Points
Formatting Conditionals
Classes &
Names & Functions & Error
Objects
Comments Handling
Variables Code Length Deep Missing
Formatting Nesting Distinction
Functions Good & Bad Parameters
Missing Bloated
Comments Error Classes
Classes Handling
Solutions
Test-Driven
Rules & Concepts Patterns & Principles
Development
Course Sections Content
Problems, Rules &
Demos & Examples Challenge Time!
Concepts
Learn about bad code See bad and code code in Analyze and transform
and why it’s bad action code on your own
Understand the core rules Bad to good code
and concepts you should transformations & Apply what you learned
follow examples
Course Prerequisites
Programming experience is required
You don’t need to be a senior
(not at all)
Programming Languages Used In This Course
Python JavaScript / TypeScript
You don’t need to know or focus on these languages
The concepts taught and examples shown apply to ALL
programming languages
Core Syntax
Variables & Constants
Functions
Classes & Interfaces
Clean Code Doesn’t Require Strict Typing
function add(num1: number, num2: number) { Types can help
return num1 + num2; preventing errors and can
} improve readability
But code can also be
def add(num1, num2):
100% readable and
return num1 + num2
meaningful without types
About The Code Examples Shown In This Course
Short, Focused Examples
Code snippets: Most examples
won’t execute
Examples don’t use a particular
programming style / paradigm
Functional vs OOP vs Procedural
This course doesn’t focus on a specific paradigm
Paradigm-specific rules, conventions, patterns and guides should
also be considered
The rules, concepts, ideas and patterns
shown in this course apply in general!
The Core Principles & Rules Always Apply!
No matter which programming
language or style you’re using…
…you still want readable …you still want slim, concise …you still want
and meaningful names functions or methods understandable code flow
Clean Code and Patterns & Principles
Patterns & Principles Clean Code
Write code which is Write code which is readable
maintainable and extensible & easy to understand
Clean Code vs Clean Architecture
Co u rse
T h is
Clean Code Clean Architecture
How to write the code Where to write which code
Focus on single problems / files Focus on the project as a whole
Clean Code Is Written Over Time!
Of course you want to write your best
code right from the beginning
You will always find ways of As your project evolves and changes,
improving your code your code will need to change
Question old code and refactor a lot!
How To Write Clean Code
Plan Project
Start a New
Features, Data Start Writing Code
Project
Entities etc.
Refactor
Feature D Feature C Feature B Feature A
Refactor
(Adjust functions,
Prototype /
Review Code / rename variables)
Release Candidate
Improve Code
Finished
Embrace Refactoring!
Refactoring today is work you save tomorrow
A codebase can only survive and stay maintainable if it’s
continuously improved and refactored
Pro tip: Whenever you add something new, try to improve
existing code along the way
Clean Code vs Quick Code
Working Code, Output
Dirty Code
Clean Code
Time