SlideShare une entreprise Scribd logo
1  sur  22
CLEAN CODE
SIRAR SALIH
.NET CONSULTANT
In theory, it’s about...

SOLID

16.01.2014

/

2
In theory, it’s about...

S ingle responsibility principle
O pen/closed principle
L iskov substitution principle
I nterface segragation principle
D ependency inversion principle
16.01.2014

/

3
In practice, it’s all about... RTM

Readability
Testability
Maintainability

16.01.2014

/

4
Readable Code

«Programming is the art of telling another human what
one wants the computer to do.» - Donald Knuth

16.01.2014

/

5
Readable Code

«Programming is the art of telling another human what
one wants the computer to do.» - Donald Knuth
From http://www.osnews.com

16.01.2014

/

6
Readable Code

«Programming is the art of telling another human what
one wants the computer to do.» - Donald Knuth

From Pluralsight

16.01.2014

/

7
Readable Code
• 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!
«Programming is the art of telling another human what
one wants the computer to do.» - Donald Knuth

16.01.2014

/

8
Readable Code

Bad

«Programming is the art of telling another human what
one wants the computer to do.» - Donald Knuth

Better

16.01.2014

/

9
Testable Code
•
•
•
•
•
•
•

Making it testable, is making it clean
Isolation
Decoupling
Separation of concerns
TDD
Design
Clean is the side effect of testable

16.01.2014 /

10
Testable Code

«You know you should be unit testing, so
why aren’t you doing it?» - Roy Osherove

16.01.2014 /

11
Testable Code
Bad

Good

16.01.2014 /

12
Maintainable Code

16.01.2014 /

13
Maintainable Code
•
•
•
•
•
•
•

Easy to extend
A change requires one change, not ten
Easy to understand
Unbrittle
Test coverage
Spreads optimism
Importance level: Readable > maintainable

16.01.2014 /

14
Bad Code

16.01.2014 /

15
Good Code

16.01.2014 /

16
The Evil Cycle

From http://blog.codeclimate.com/

16.01.2014 /

17
Be an Agent of Change

16.01.2014 /

18
Fight Code Smells and Anti-Patterns
•
•
•
•
•
•
•
•

Comments
Duplication
Global objects
Magic numbers
Circular dependency
Coupling
Nesting
Dead code

16.01.2014 /

19
Make it Routine

16.01.2014 /

20
Recommended Books

16.01.2014 /

21
Thank you  / Questions

Blog: http://sirars.com/
• sirar.salih@itera.no / sirars@gmail.com
• @SirarSalih

Contenu connexe

Similaire à Clean Code

Session 2 - Libraries and Open Source
Session 2 - Libraries and Open SourceSession 2 - Libraries and Open Source
Session 2 - Libraries and Open SourceJonathan Field
 
10 Things Every PHP Developer Should Know About Machine Learning
10 Things Every PHP Developer Should Know About Machine Learning10 Things Every PHP Developer Should Know About Machine Learning
10 Things Every PHP Developer Should Know About Machine LearningChristopher Mohritz
 
Death by a thousand paper cuts — Alexandra Leisse - Codemotion Amsterdam 2017
Death by a thousand paper cuts — Alexandra Leisse - Codemotion Amsterdam 2017Death by a thousand paper cuts — Alexandra Leisse - Codemotion Amsterdam 2017
Death by a thousand paper cuts — Alexandra Leisse - Codemotion Amsterdam 2017Codemotion
 
10 Things Every PHP Developer Should Know About Machine Learning
10 Things Every PHP Developer Should Know About Machine Learning10 Things Every PHP Developer Should Know About Machine Learning
10 Things Every PHP Developer Should Know About Machine Learning10x Nation
 
FoundationsOfUserInterfaceDesign
FoundationsOfUserInterfaceDesignFoundationsOfUserInterfaceDesign
FoundationsOfUserInterfaceDesignSinsentido2
 
Everyone's a Coder Now: Reading and Writing Technical Code
Everyone's a Coder Now: Reading and Writing Technical CodeEveryone's a Coder Now: Reading and Writing Technical Code
Everyone's a Coder Now: Reading and Writing Technical CodeJulie Meloni
 
New text document
New text documentNew text document
New text documentsleucwnq
 
New text document
New text documentNew text document
New text documentsleucwnq
 
Are Computer Ethical Issues Unique ?
Are Computer Ethical Issues Unique ?Are Computer Ethical Issues Unique ?
Are Computer Ethical Issues Unique ?VARUN KUMAR
 
Blackhat 2014 Conference and Defcon 22
Blackhat 2014 Conference and Defcon 22 Blackhat 2014 Conference and Defcon 22
Blackhat 2014 Conference and Defcon 22 dandb-technology
 
Foss final seminar
Foss final seminarFoss final seminar
Foss final seminarSmit Patil
 
Foss final seminar
Foss final seminarFoss final seminar
Foss final seminarSmit Patil
 
Design of everyday things fundamental principles of interaction - V2
Design of everyday things   fundamental principles of interaction - V2Design of everyday things   fundamental principles of interaction - V2
Design of everyday things fundamental principles of interaction - V2Isaac Liao
 
Automate your Job and Business with ChatGPT #3 - Fundamentals of LLM/GPT
Automate your Job and Business with ChatGPT #3 - Fundamentals of LLM/GPTAutomate your Job and Business with ChatGPT #3 - Fundamentals of LLM/GPT
Automate your Job and Business with ChatGPT #3 - Fundamentals of LLM/GPTAnant Corporation
 
Designing for mobile. A UX perspective for developers
Designing for mobile. A UX perspective for developersDesigning for mobile. A UX perspective for developers
Designing for mobile. A UX perspective for developersOscar Gonzalez Garza
 
Clean Code I - Best Practices
Clean Code I - Best PracticesClean Code I - Best Practices
Clean Code I - Best PracticesTheo Jungeblut
 
Open source a presentation
Open source   a presentationOpen source   a presentation
Open source a presentationAmol Vidwans
 
The Past and Future of Open Computing
The Past and Future of Open ComputingThe Past and Future of Open Computing
The Past and Future of Open ComputingTim O'Reilly
 

Similaire à Clean Code (20)

Torocpsummit 130116180230-phpapp02
Torocpsummit 130116180230-phpapp02Torocpsummit 130116180230-phpapp02
Torocpsummit 130116180230-phpapp02
 
Session 2 - Libraries and Open Source
Session 2 - Libraries and Open SourceSession 2 - Libraries and Open Source
Session 2 - Libraries and Open Source
 
10 Things Every PHP Developer Should Know About Machine Learning
10 Things Every PHP Developer Should Know About Machine Learning10 Things Every PHP Developer Should Know About Machine Learning
10 Things Every PHP Developer Should Know About Machine Learning
 
Death by a thousand paper cuts — Alexandra Leisse - Codemotion Amsterdam 2017
Death by a thousand paper cuts — Alexandra Leisse - Codemotion Amsterdam 2017Death by a thousand paper cuts — Alexandra Leisse - Codemotion Amsterdam 2017
Death by a thousand paper cuts — Alexandra Leisse - Codemotion Amsterdam 2017
 
Crafting Great Code
Crafting Great CodeCrafting Great Code
Crafting Great Code
 
10 Things Every PHP Developer Should Know About Machine Learning
10 Things Every PHP Developer Should Know About Machine Learning10 Things Every PHP Developer Should Know About Machine Learning
10 Things Every PHP Developer Should Know About Machine Learning
 
FoundationsOfUserInterfaceDesign
FoundationsOfUserInterfaceDesignFoundationsOfUserInterfaceDesign
FoundationsOfUserInterfaceDesign
 
Everyone's a Coder Now: Reading and Writing Technical Code
Everyone's a Coder Now: Reading and Writing Technical CodeEveryone's a Coder Now: Reading and Writing Technical Code
Everyone's a Coder Now: Reading and Writing Technical Code
 
New text document
New text documentNew text document
New text document
 
New text document
New text documentNew text document
New text document
 
Are Computer Ethical Issues Unique ?
Are Computer Ethical Issues Unique ?Are Computer Ethical Issues Unique ?
Are Computer Ethical Issues Unique ?
 
Blackhat 2014 Conference and Defcon 22
Blackhat 2014 Conference and Defcon 22 Blackhat 2014 Conference and Defcon 22
Blackhat 2014 Conference and Defcon 22
 
Foss final seminar
Foss final seminarFoss final seminar
Foss final seminar
 
Foss final seminar
Foss final seminarFoss final seminar
Foss final seminar
 
Design of everyday things fundamental principles of interaction - V2
Design of everyday things   fundamental principles of interaction - V2Design of everyday things   fundamental principles of interaction - V2
Design of everyday things fundamental principles of interaction - V2
 
Automate your Job and Business with ChatGPT #3 - Fundamentals of LLM/GPT
Automate your Job and Business with ChatGPT #3 - Fundamentals of LLM/GPTAutomate your Job and Business with ChatGPT #3 - Fundamentals of LLM/GPT
Automate your Job and Business with ChatGPT #3 - Fundamentals of LLM/GPT
 
Designing for mobile. A UX perspective for developers
Designing for mobile. A UX perspective for developersDesigning for mobile. A UX perspective for developers
Designing for mobile. A UX perspective for developers
 
Clean Code I - Best Practices
Clean Code I - Best PracticesClean Code I - Best Practices
Clean Code I - Best Practices
 
Open source a presentation
Open source   a presentationOpen source   a presentation
Open source a presentation
 
The Past and Future of Open Computing
The Past and Future of Open ComputingThe Past and Future of Open Computing
The Past and Future of Open Computing
 

Plus de Sirar Salih

Azure Table Storage: The Good, the Bad, the Ugly (15 min. lightning talk)
Azure Table Storage: The Good, the Bad, the Ugly (15 min. lightning talk)Azure Table Storage: The Good, the Bad, the Ugly (15 min. lightning talk)
Azure Table Storage: The Good, the Bad, the Ugly (15 min. lightning talk)Sirar Salih
 
Azure Table Storage: The Good, the Bad, the Ugly (full talk)
Azure Table Storage: The Good, the Bad, the Ugly (full talk)Azure Table Storage: The Good, the Bad, the Ugly (full talk)
Azure Table Storage: The Good, the Bad, the Ugly (full talk)Sirar Salih
 
Azure Table Storage: The Good, the Bad, the Ugly (10 min. lightning talk)
Azure Table Storage: The Good, the Bad, the Ugly (10 min. lightning talk)Azure Table Storage: The Good, the Bad, the Ugly (10 min. lightning talk)
Azure Table Storage: The Good, the Bad, the Ugly (10 min. lightning talk)Sirar Salih
 
Test Driven Development with AngularJS
Test Driven Development with AngularJSTest Driven Development with AngularJS
Test Driven Development with AngularJSSirar Salih
 
One Framework to Rule Them All
One Framework to Rule Them AllOne Framework to Rule Them All
One Framework to Rule Them AllSirar Salih
 
Introduction to WPF and MVVM
Introduction to WPF and MVVMIntroduction to WPF and MVVM
Introduction to WPF and MVVMSirar Salih
 
Angularfying Your ASP.NET MVC APP
Angularfying Your ASP.NET MVC APPAngularfying Your ASP.NET MVC APP
Angularfying Your ASP.NET MVC APPSirar Salih
 

Plus de Sirar Salih (7)

Azure Table Storage: The Good, the Bad, the Ugly (15 min. lightning talk)
Azure Table Storage: The Good, the Bad, the Ugly (15 min. lightning talk)Azure Table Storage: The Good, the Bad, the Ugly (15 min. lightning talk)
Azure Table Storage: The Good, the Bad, the Ugly (15 min. lightning talk)
 
Azure Table Storage: The Good, the Bad, the Ugly (full talk)
Azure Table Storage: The Good, the Bad, the Ugly (full talk)Azure Table Storage: The Good, the Bad, the Ugly (full talk)
Azure Table Storage: The Good, the Bad, the Ugly (full talk)
 
Azure Table Storage: The Good, the Bad, the Ugly (10 min. lightning talk)
Azure Table Storage: The Good, the Bad, the Ugly (10 min. lightning talk)Azure Table Storage: The Good, the Bad, the Ugly (10 min. lightning talk)
Azure Table Storage: The Good, the Bad, the Ugly (10 min. lightning talk)
 
Test Driven Development with AngularJS
Test Driven Development with AngularJSTest Driven Development with AngularJS
Test Driven Development with AngularJS
 
One Framework to Rule Them All
One Framework to Rule Them AllOne Framework to Rule Them All
One Framework to Rule Them All
 
Introduction to WPF and MVVM
Introduction to WPF and MVVMIntroduction to WPF and MVVM
Introduction to WPF and MVVM
 
Angularfying Your ASP.NET MVC APP
Angularfying Your ASP.NET MVC APPAngularfying Your ASP.NET MVC APP
Angularfying Your ASP.NET MVC APP
 

Dernier

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Dernier (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Clean Code

Notes de l'éditeur

  1. Single responsibility principlethe notion that an object should have only a single responsibility.Open/closed principlethe notion that “software entities … should be open for extension, but closed for modification”.Liskov substitution principlethe notion that “objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program”. Interface segregation principlethe notion that “many client specific interfaces are better than one general purpose interface.”Dependency inversion principlethe notion that one should “Depend upon Abstractions. Do not depend upon concretions.”[5]Dependency injection is one method of following this principle.