clean code
DESCRIPTION
TRANSCRIPT
CLEAN CODE
SIRAR SALIH
.NET CONSULTANT
08.04.2023
In theory, it’s about...
SOLID
/ 2
08.04.2023
In theory, it’s about...
/ 3
SOLID
ingle responsibility principle
pen/closed principle
iskov substitution principle
nterface segragation principle
ependency inversion principle
08.04.2023
In practice, it’s all about... RTM
/ 4
ReadabilityTestability
Maintainability
08.04.2023
Readable Code
/ 5
«Programming is the art of telling another human what one wants the computer to do.» - Donald Knuth
08.04.2023
Readable Code
/ 6
«Programming is the art of telling another human what one wants the computer to do.» - Donald Knuth
From http://www.osnews.com
08.04.2023
Readable Code
/ 7
«Programming is the art of telling another human what one wants the computer to do.» - Donald Knuth
From Pluralsight
08.04.2023
Readable Code
/ 8
«Programming is the art of telling another human what one wants the computer to do.» - Donald Knuth
• Readable code is understandable code• Naming
Class names Context specific
Method names Say exactly what they do
• The don’ts Don’t confuse Don’t hide Don’t joke Don’t be informal
• Tell a story!
08.04.2023
Readable Code
/ 9
«Programming is the art of telling another human what one wants the computer to do.» - Donald Knuth
Bad
Better
08.04.2023
Testable Code
/ 10
• Making it testable, is making it clean• Isolation• Decoupling• Separation of concerns• TDD• Design• Clean is the side effect of testable
08.04.2023
Testable Code
/ 11
«You know you should be unit testing, so why aren’t you doing it?» - Roy Osherove
08.04.2023
Testable Code
/ 12
Bad Good
08.04.2023
Maintainable Code
/ 13
08.04.2023
Maintainable Code
/ 14
• Easy to extend• A change requires one change, not ten• Easy to understand• Unbrittle• Test coverage• Spreads optimism• Importance level: Readable > maintainable
08.04.2023
Bad Code
/ 15
08.04.2023
Good Code
/ 16
08.04.2023
The Evil Cycle
/ 17
From http://blog.codeclimate.com/
08.04.2023
Be an Agent of Change
/ 18
08.04.2023
Fight Code Smells and Anti-Patterns
/ 19
• Comments• Duplication• Global objects• Magic numbers• Circular dependency• Coupling• Nesting• Dead code
08.04.2023
Make it Routine
/ 20
08.04.2023
Recommended Books
/ 21
Thank you / Questions
Blog: http://sirars.com/ • [email protected] / [email protected]• @SirarSalih