SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Mais 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
 

Mais 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
 

Último

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
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
 
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 future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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 Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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
 

Último (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
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
 
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 future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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 Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 

Clean Code

Notas do Editor

  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.