SlideShare uma empresa Scribd logo
1 de 20
1CONFIDENTIAL
Caring About Code
Quality
Tamas Korozsi
2015
2CONFIDENTIAL
ME
3CONFIDENTIAL
Clean Code: A Handbook of Agile Software Craftsmanship
by Robert C. Martin
The Book
4CONFIDENTIAL
Does it work?
What is Clean Code?
Does it scale?
Is it esthetic?
Is it maintainable?
Is it testable?
Is it short?
Is it clever?
Does it have explanatory
comments?
Is it easy to
understand?
Is it well-structured?
Is it object-oriented?
5CONFIDENTIAL
• Focused
• Single-minded attitude
• Undistracted and unpolluted
• Readable, simple and direct
• Compact and literate
• Contains only what is necessary
• Makes it easy for other developers to enhance it
• Tests should be also clean
• Looks like it’s author cares
• Contains no duplicates
• Foundations are established on tiny abstractions
What is Clean Code after all?
6CONFIDENTIAL
• Subjective
• If you can’t measure, you can’t improve
• Identify what matters
• Defend and justify decisions.
The need for measurement
7CONFIDENTIAL
Cyclomatic complexity
public void foo() {
if (c1) {
f1();
} else {
f2();
}
if (c2) {
f3();
} else {
f4();
}
}
• Upper bound for the number of test cases
that are necessary to achieve a complete
branch coverage
• Lower bound for the number of paths
through the control flow graph
• Desirable value: below 10
Cyclomatic complexity: 3
8CONFIDENTIAL
Always leave the campground
cleaner than you found it.
The Boy Scout Rule
9CONFIDENTIAL
• Came from city crime researchers
• A broken window will trigger a building into a
smashed and abandoned derelict
• So does the software
Broken Window Theory
10CONFIDENTIAL
Composed method example
public void add(Object element) {
if (!readOnly) {
int newSize = size + 1;
if (newSize > elements.length) {
Object[] newElements = new Object[elements.length + 10];
for (int index = 0; index < size; index++) {
newElements[index] = elements[index];
elements = newElements;
}
}
elements[size++] = element;
}
}
11CONFIDENTIAL
Implementation patterns
12CONFIDENTIAL
• Divide your program into methods that perform one identifiable task
• Keep all of the operation in a method at a same level of abstraction
• This will naturally result in programs with many small methods, each
few lines long.
Composed method pattern by Kent Beck
13CONFIDENTIAL
Composed method example
public void add(Object element) {
if (!isReadOnly()) {
if (atCapacity()) {
grow();
}
addElement(element);
}
}
14CONFIDENTIAL
• Instant feedback
• Allows you to make changes to code quickly
• Help you understand the design of the code you
are working on
• Writing testable code helps to achieve better
code quality
• Unit tests are a form of sample code
• Test-first forces you to plan before you code
Advantages of Unit tests
15CONFIDENTIAL
• Whether the unit you're testing should be
isolated from its collaborators
• Mockist approach
– Isolate from dependencies
– More flexible in what you can test
• Classic approach
– No attempt to isolate unless communicating
with the collaborator is awkward
– Less brittle tests
Unit tests collaborator isolation
16CONFIDENTIAL
• Change Risk Analysis and Prediction
• Help you identify code that might be particularly difficult to
understand, test, or maintain
• 𝐶𝑅𝐴𝑃 𝑚 = cycl_comp(m)2
∗ 1 − 𝑐𝑜𝑣𝑒𝑟𝑎𝑔𝑒
3
+ cycl_comp(m)
• A method with a CRAP score over 30 is considered
unacceptable
C.R.A.P. metric
Cyclomatic
Complexity
Coverage
required
0 – 5 0%
10 42%
15 57%
20 71%
25 80%
30 100%
31+ Not possible
17CONFIDENTIAL
• Don’t build complex machines
• Don’t build frameworks
• Make the software so simple that there are
obviously no deficiencies
• Keep it simple, stupid (KISS)
Rube Goldberg Machines
18CONFIDENTIAL
• Avoid Cargo cult programming
• Question authority
• Accept feedback and give feedback
Angry monkeys experiment
19CONFIDENTIAL
EPAM Academy
Aniko_b
20CONFIDENTIAL
TAMAS_KOROZSI@EPAM.COM
THANK YOU FOR ATTENTION!
QUESTIONS?

Mais conteúdo relacionado

Mais procurados

The tests are trying to tell you something@VoxxedBucharest.pptx
The tests are trying to tell you something@VoxxedBucharest.pptxThe tests are trying to tell you something@VoxxedBucharest.pptx
The tests are trying to tell you something@VoxxedBucharest.pptxVictor Rentea
 
The Art of Clean code
The Art of Clean codeThe Art of Clean code
The Art of Clean codeVictor Rentea
 
A Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidA Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidOutware Mobile
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentJohn Blum
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguestc8093a6
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code SmellsMario Sangiorgio
 
Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#Svetlin Nakov
 
An introduction to property based testing
An introduction to property based testingAn introduction to property based testing
An introduction to property based testingScott Wlaschin
 
Functional Patterns with Java8 @Bucharest Java User Group
Functional Patterns with Java8 @Bucharest Java User GroupFunctional Patterns with Java8 @Bucharest Java User Group
Functional Patterns with Java8 @Bucharest Java User GroupVictor Rentea
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelinesAnkur Goyal
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And RefactoringNaresh Jain
 
Clean Code Principles
Clean Code PrinciplesClean Code Principles
Clean Code PrinciplesYeurDreamin'
 

Mais procurados (20)

The tests are trying to tell you something@VoxxedBucharest.pptx
The tests are trying to tell you something@VoxxedBucharest.pptxThe tests are trying to tell you something@VoxxedBucharest.pptx
The tests are trying to tell you something@VoxxedBucharest.pptx
 
The Art of Clean code
The Art of Clean codeThe Art of Clean code
The Art of Clean code
 
A Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidA Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on Android
 
Clean code
Clean codeClean code
Clean code
 
Clean code: SOLID
Clean code: SOLIDClean code: SOLID
Clean code: SOLID
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Clean code
Clean codeClean code
Clean code
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code Smells
 
Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#
 
An introduction to property based testing
An introduction to property based testingAn introduction to property based testing
An introduction to property based testing
 
Functional Patterns with Java8 @Bucharest Java User Group
Functional Patterns with Java8 @Bucharest Java User GroupFunctional Patterns with Java8 @Bucharest Java User Group
Functional Patterns with Java8 @Bucharest Java User Group
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelines
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 
Clean Code
Clean CodeClean Code
Clean Code
 
Teste de software
Teste de softwareTeste de software
Teste de software
 
Clean Code Principles
Clean Code PrinciplesClean Code Principles
Clean Code Principles
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Clean code
Clean codeClean code
Clean code
 
Exploratory test
Exploratory testExploratory test
Exploratory test
 

Semelhante a clean code - uncle bob

Caring About Code Quality (Clean Code, GRASP, Effective Java, Design Pattern)
Caring About Code Quality (Clean Code, GRASP, Effective Java, Design Pattern)Caring About Code Quality (Clean Code, GRASP, Effective Java, Design Pattern)
Caring About Code Quality (Clean Code, GRASP, Effective Java, Design Pattern)El Mahdi Benzekri
 
Agile Software Development and Test Driven Development: Agil8's Dave Putman 3...
Agile Software Development and Test Driven Development: Agil8's Dave Putman 3...Agile Software Development and Test Driven Development: Agil8's Dave Putman 3...
Agile Software Development and Test Driven Development: Agil8's Dave Putman 3...agil8 Ltd
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptxAmalEldhose2
 
Is your code SOLID enough?
 Is your code SOLID enough? Is your code SOLID enough?
Is your code SOLID enough?SARCCOM
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentShawn Jones
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesIgor Moochnick
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applicationsnadeembtech
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference CardSeapine Software
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentationBhavin Gandhi
 
Adopting Agile
Adopting AgileAdopting Agile
Adopting AgileCoverity
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable codeMarko Heijnen
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code ReviewMilan Vukoje
 

Semelhante a clean code - uncle bob (20)

Caring About Code Quality (Clean Code, GRASP, Effective Java, Design Pattern)
Caring About Code Quality (Clean Code, GRASP, Effective Java, Design Pattern)Caring About Code Quality (Clean Code, GRASP, Effective Java, Design Pattern)
Caring About Code Quality (Clean Code, GRASP, Effective Java, Design Pattern)
 
Agile Software Development and Test Driven Development: Agil8's Dave Putman 3...
Agile Software Development and Test Driven Development: Agil8's Dave Putman 3...Agile Software Development and Test Driven Development: Agil8's Dave Putman 3...
Agile Software Development and Test Driven Development: Agil8's Dave Putman 3...
 
Clean Code Talk (draft)
Clean Code Talk (draft)Clean Code Talk (draft)
Clean Code Talk (draft)
 
Best pratice
Best praticeBest pratice
Best pratice
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx
 
Clean code chpt_1
Clean code chpt_1Clean code chpt_1
Clean code chpt_1
 
TDD in Agile
TDD in AgileTDD in Agile
TDD in Agile
 
Is your code SOLID enough?
 Is your code SOLID enough? Is your code SOLID enough?
Is your code SOLID enough?
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven Development
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best Practices
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applications
 
Tdd
TddTdd
Tdd
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference Card
 
Tdd and bdd
Tdd and bddTdd and bdd
Tdd and bdd
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentation
 
Code Reviews
Code ReviewsCode Reviews
Code Reviews
 
Adopting Agile
Adopting AgileAdopting Agile
Adopting Agile
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable code
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code Review
 

Mais de saber tabatabaee

clean architecture uncle bob AnalysisAndDesign.el.en.pptx
clean architecture uncle bob AnalysisAndDesign.el.en.pptxclean architecture uncle bob AnalysisAndDesign.el.en.pptx
clean architecture uncle bob AnalysisAndDesign.el.en.pptxsaber tabatabaee
 
هاستینگ و راه اندازی یک پروژه لاراول - آنالیز و امکان سنجی
هاستینگ و راه اندازی یک پروژه لاراول - آنالیز و امکان سنجیهاستینگ و راه اندازی یک پروژه لاراول - آنالیز و امکان سنجی
هاستینگ و راه اندازی یک پروژه لاراول - آنالیز و امکان سنجیsaber tabatabaee
 
لاراول ارائه 26 سپتامبر 2021 اسکایپ
لاراول ارائه 26 سپتامبر 2021 اسکایپلاراول ارائه 26 سپتامبر 2021 اسکایپ
لاراول ارائه 26 سپتامبر 2021 اسکایپsaber tabatabaee
 
scrum master اسکرام مستر
scrum master اسکرام مسترscrum master اسکرام مستر
scrum master اسکرام مسترsaber tabatabaee
 
Scrum master - daily scrum master story
Scrum master - daily scrum master storyScrum master - daily scrum master story
Scrum master - daily scrum master storysaber tabatabaee
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionsaber tabatabaee
 
teaching data science students to write clean code
teaching data science students to write clean codeteaching data science students to write clean code
teaching data science students to write clean codesaber tabatabaee
 
Writing clean scientific software Murphy cleancoding
Writing clean scientific software Murphy cleancodingWriting clean scientific software Murphy cleancoding
Writing clean scientific software Murphy cleancodingsaber tabatabaee
 
R. herves. clean code (theme)2
R. herves. clean code (theme)2R. herves. clean code (theme)2
R. herves. clean code (theme)2saber tabatabaee
 
refactoring code by clean code rules
refactoring code by clean code rulesrefactoring code by clean code rules
refactoring code by clean code rulessaber tabatabaee
 
sharepoint 2007 presentation in crcis
sharepoint 2007 presentation in crcis sharepoint 2007 presentation in crcis
sharepoint 2007 presentation in crcis saber tabatabaee
 
Linux DVD 03 Learnkey linux+ setup
Linux DVD 03 Learnkey linux+ setupLinux DVD 03 Learnkey linux+ setup
Linux DVD 03 Learnkey linux+ setupsaber tabatabaee
 

Mais de saber tabatabaee (17)

clean architecture uncle bob AnalysisAndDesign.el.en.pptx
clean architecture uncle bob AnalysisAndDesign.el.en.pptxclean architecture uncle bob AnalysisAndDesign.el.en.pptx
clean architecture uncle bob AnalysisAndDesign.el.en.pptx
 
هاستینگ و راه اندازی یک پروژه لاراول - آنالیز و امکان سنجی
هاستینگ و راه اندازی یک پروژه لاراول - آنالیز و امکان سنجیهاستینگ و راه اندازی یک پروژه لاراول - آنالیز و امکان سنجی
هاستینگ و راه اندازی یک پروژه لاراول - آنالیز و امکان سنجی
 
لاراول ارائه 26 سپتامبر 2021 اسکایپ
لاراول ارائه 26 سپتامبر 2021 اسکایپلاراول ارائه 26 سپتامبر 2021 اسکایپ
لاراول ارائه 26 سپتامبر 2021 اسکایپ
 
scrum master اسکرام مستر
scrum master اسکرام مسترscrum master اسکرام مستر
scrum master اسکرام مستر
 
L5 swagger
L5 swaggerL5 swagger
L5 swagger
 
Crm or xrm
Crm or xrmCrm or xrm
Crm or xrm
 
Scrum master - daily scrum master story
Scrum master - daily scrum master storyScrum master - daily scrum master story
Scrum master - daily scrum master story
 
Online exam ismc
Online exam ismcOnline exam ismc
Online exam ismc
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English version
 
teaching data science students to write clean code
teaching data science students to write clean codeteaching data science students to write clean code
teaching data science students to write clean code
 
Writing clean scientific software Murphy cleancoding
Writing clean scientific software Murphy cleancodingWriting clean scientific software Murphy cleancoding
Writing clean scientific software Murphy cleancoding
 
R. herves. clean code (theme)2
R. herves. clean code (theme)2R. herves. clean code (theme)2
R. herves. clean code (theme)2
 
Code quality
Code qualityCode quality
Code quality
 
refactoring code by clean code rules
refactoring code by clean code rulesrefactoring code by clean code rules
refactoring code by clean code rules
 
sharepoint 2007 presentation in crcis
sharepoint 2007 presentation in crcis sharepoint 2007 presentation in crcis
sharepoint 2007 presentation in crcis
 
Linux DVD 03 Learnkey linux+ setup
Linux DVD 03 Learnkey linux+ setupLinux DVD 03 Learnkey linux+ setup
Linux DVD 03 Learnkey linux+ setup
 
linux+ learnkey DVD 2
linux+ learnkey DVD 2 linux+ learnkey DVD 2
linux+ learnkey DVD 2
 

Último

The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Último (20)

The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

clean code - uncle bob

  • 3. 3CONFIDENTIAL Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin The Book
  • 4. 4CONFIDENTIAL Does it work? What is Clean Code? Does it scale? Is it esthetic? Is it maintainable? Is it testable? Is it short? Is it clever? Does it have explanatory comments? Is it easy to understand? Is it well-structured? Is it object-oriented?
  • 5. 5CONFIDENTIAL • Focused • Single-minded attitude • Undistracted and unpolluted • Readable, simple and direct • Compact and literate • Contains only what is necessary • Makes it easy for other developers to enhance it • Tests should be also clean • Looks like it’s author cares • Contains no duplicates • Foundations are established on tiny abstractions What is Clean Code after all?
  • 6. 6CONFIDENTIAL • Subjective • If you can’t measure, you can’t improve • Identify what matters • Defend and justify decisions. The need for measurement
  • 7. 7CONFIDENTIAL Cyclomatic complexity public void foo() { if (c1) { f1(); } else { f2(); } if (c2) { f3(); } else { f4(); } } • Upper bound for the number of test cases that are necessary to achieve a complete branch coverage • Lower bound for the number of paths through the control flow graph • Desirable value: below 10 Cyclomatic complexity: 3
  • 8. 8CONFIDENTIAL Always leave the campground cleaner than you found it. The Boy Scout Rule
  • 9. 9CONFIDENTIAL • Came from city crime researchers • A broken window will trigger a building into a smashed and abandoned derelict • So does the software Broken Window Theory
  • 10. 10CONFIDENTIAL Composed method example public void add(Object element) { if (!readOnly) { int newSize = size + 1; if (newSize > elements.length) { Object[] newElements = new Object[elements.length + 10]; for (int index = 0; index < size; index++) { newElements[index] = elements[index]; elements = newElements; } } elements[size++] = element; } }
  • 12. 12CONFIDENTIAL • Divide your program into methods that perform one identifiable task • Keep all of the operation in a method at a same level of abstraction • This will naturally result in programs with many small methods, each few lines long. Composed method pattern by Kent Beck
  • 13. 13CONFIDENTIAL Composed method example public void add(Object element) { if (!isReadOnly()) { if (atCapacity()) { grow(); } addElement(element); } }
  • 14. 14CONFIDENTIAL • Instant feedback • Allows you to make changes to code quickly • Help you understand the design of the code you are working on • Writing testable code helps to achieve better code quality • Unit tests are a form of sample code • Test-first forces you to plan before you code Advantages of Unit tests
  • 15. 15CONFIDENTIAL • Whether the unit you're testing should be isolated from its collaborators • Mockist approach – Isolate from dependencies – More flexible in what you can test • Classic approach – No attempt to isolate unless communicating with the collaborator is awkward – Less brittle tests Unit tests collaborator isolation
  • 16. 16CONFIDENTIAL • Change Risk Analysis and Prediction • Help you identify code that might be particularly difficult to understand, test, or maintain • 𝐶𝑅𝐴𝑃 𝑚 = cycl_comp(m)2 ∗ 1 − 𝑐𝑜𝑣𝑒𝑟𝑎𝑔𝑒 3 + cycl_comp(m) • A method with a CRAP score over 30 is considered unacceptable C.R.A.P. metric Cyclomatic Complexity Coverage required 0 – 5 0% 10 42% 15 57% 20 71% 25 80% 30 100% 31+ Not possible
  • 17. 17CONFIDENTIAL • Don’t build complex machines • Don’t build frameworks • Make the software so simple that there are obviously no deficiencies • Keep it simple, stupid (KISS) Rube Goldberg Machines
  • 18. 18CONFIDENTIAL • Avoid Cargo cult programming • Question authority • Accept feedback and give feedback Angry monkeys experiment