Want to create interactive content? It’s easy in Genially!
Clean Code grade 1
Chonlaphoom Thaiyanto
Created on March 7, 2023
Start designing with a free template
Discover more than 1500 professional designs like these:
Transcript
Clean Code Developer
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. —Martin Fowler
Coding is not about languages. It's about algorithm and data. There are only various of practices and design patterns. The actual writing of lines of code is probably only 10% of the whole process.
Smell Code
Yoda Condition
Hard-coding primitive strings and numbers without descriptions
Using short, generic, or type-based variable names.
Too much comments
Long Method
The excessive use of conditional logic
Too many parameters on function
Clean Code
Simple and Direct. Reads like well-written prose.
Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control.― Robert C. Martin, Clean Code: A Handbook of Agile Software
What is Legacy Code?
Legacy Code is valuable code you’re afraid to change.
Legacy Code is the code you need to change and you struggle to understand.
Code without test for a long time.
Spaghetti Code
On the Relationship between Software Development process and Maintenance Costs
Why
Clean Code ?
Values of Clean Code
Evolvability
Correctness
Production Efficiency
Continuos Improvement
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." — John Woods
Let's do some exercise
Principal
Grade 1 Red
Don’t Repeat Yourself (DRY)
DRY Code Trade-off
Too many abstractions
External dependency creation
Localization complexity
Keep it simple, stupid (KISS)
Keep the scope of variables as small as possible.
Keep functions small and make sure they do just one thing.
Use proper naming for your variables.
YAGNI: You Aren't Gonna Need It. Do not add functionality until it is completely necessary
Most functions should be predictable and testable.
Beware of Optimizations!
Rules of Optimization:Rule 1: Don’t do it. Rule 2: Don’t do it yet.
Tips
Make it work, make it right then make it fast. - Ken Beck
Tips
Do one thing at a time
Practices
Grade 1 Red
Boy Scout Rule
Root Cause Analysis
Daily Reflection
Simple Refactoring Patterns
Everything have trade-off
Tips
1. Test concrete code.
2. Let's take a walk, delay the implementation.
3. Be ready to inline it.
cr. DeconstructSeattle, WA - Thu & Fri, Apr 23-24 2020 : the wet codebase by Dan Abramov
cr. DeconstructSeattle, WA - Thu & Fri, Apr 23-24 2020 : the wet codebase by Dan Abramov
Have fun !