SlideShare a Scribd company logo
1 of 39
Clean Code Quotes
A Handbook of Agile Software Craftsmanship
Citações e Provocações
Sobre mim
● Java desde 2006 (1.4)
● Spring Framework desde 2008 (2.5)
● Ritmista da Mocidade Alegre desde 2000
@aignacio83
andrefontanaignacio
ignacio83
Robert C. Martin - Uncle Bob
Robert Cecil Martin é um engenheiro de software desde 1970. Ele
editou e escreveu diversos livros. É co-autor do Manifesto Ágil.
Também é editor chefe na revista C++ Report e serviu para o primeiro
presidente da aliança ágil.
About bad code
"Nothing has a more profound and long-term degrading effect
upon a development project than bad code. Bad schedules can
be redone, bad requirements can be redefined. Bad team
dynamics can be repaired. But bad code rots and ferments,
becoming an inexorable weight that drags the team down."
About Learn to write Clean code
"You must practice it yourself, and watch yourself fail. You
must watch others practice it and fail. You must see them
stumble and retrace their steps. You must see them agonize
over decisions and see the price they pay for making those
decisions the wrong way."
About managers
"If I don’t do what my manager says, I’ll be fired. Probably
not. Most managers want the truth, even when they don’t act
like it. Most managers want good code, even when they are
obsessing about the schedule."
"They may defend the schedule and requirements with passion;
but that’s their job."
About unit tests
"Code, without tests, is not clean. No matter how elegant it
is, no matter how readable and accessible, if it hath not
tests, it be unclean."
About naming things
"The name of a variable, function, or class, should answer
all the big questions. It should tell you why it exists, what
it does, and how it is used. If a name requires a comment,
then the name does not reveal its intent."
About naming things - Refactor time
About functions
"Functions should do one thing. They should do It well. They
should do It only."
The first rule of functions is that they should be small. The
second rule of functions is that they should be smaller than
that.
About naming functions
"Don’t be afraid to make a name long. A long descriptive name
is better than a short enigmatic name. A long descriptive
name is better than a long descriptive comment."
About comments
"The proper use of comments is to compensate for our failure
to express ourself in code. Note that I used the word
failure. I meant it. Comments are always failures. We must
have them because we cannot always figure out how to express
ourselves without them, but their use is not a cause for
celebration."
About comments - Refactor time
About comments and Bad code
"We write a module and we know it is confusing and
disorganized. We know it’s a mess. So we say to ourselves,
“Ooh, I’d better comment that!”
No! You’d better clean it!"
About source of truth
"Truth can only be found in one place: the code. Only the
code can truly tell you what it does. It is the only source
of truly accurate information. Therefore, though comments are
sometimes necessary, we will expend significant energy to
minimize them."
About Switchs
"By their nature, switch statements always do N things.
Unfortunately we can’t always avoid switch statements, but we
can make sure that each switch statement is buried in a low-
level class and is never repeated. We do this, of course,
with polymorphism."
About Switchs - Close Looking
"There are several problems with this
function. First, it’s large, and when
new employee types are added, it will
grow. Second, it very clearly does more
than one thing. Third, it violates the
Single Responsibility Principle because
there is more than one reason for it to
change. Fourth, it violates the Open
Closed Principle (OCP) because it must
change whenever new types are added. But
possibly the worst problem with this
function is that there are an unlimited
number of other functions that will have
the same structure."
About Switchs - Refactor time
About variables declaration
"Variables should be declared as close to their usage as
possible."
About dependent functions
"If one function calls another, they should be vertically
close, and the caller should be above the callee, if at all
possible. This gives the program a natural flow."
About encapsulation
"There is a reason that we keep our variables private. We
don’t want anyone else to depend on them. We want to keep the
freedom to change their type or implementation impulse. Why,
then, do so many programmers automatically add getters and
setters to their objects, exposing their private variables as
if they were public?"
About Data Structures and Objects
"Objects hide their data behind abstractions and expose
functions that operate on that data. Data structure expose
their data and have no meaningful functions."
About Data Structures and Objects - Refactor time
About Procedural code and OO
"Procedural code (code using data structures) makes it easy
to add new functions without changing the existing data
structures. OO code, on the other hand, makes it easy to add
new classes without changing existing functions.
The complement is also true:
Procedural code makes it hard to add new data structures
because all the functions must change. OO code makes it hard
to add new functions because all the classes must change."
About Train Wreck
"This kind of code is often called a train wreck because it
look like a bunch of coupled train cars. Chains of calls like
this are generally considered to be sloppy style and should
be avoided. It is usually best to split them up as follows:"
Options opts = ctxt.getOptions();
File scratchDir = opts.getScratchDir();
String outputDir = scratchDir.getAbsolutePath();
final String outputDir = ctxt.getOptions().getScratchDir().getAbsolutePath();
About Checked Exceptions
"The price of checked exceptions is an Open/Closed Principle
violation. If you throw a checked exception from a method in
your code and the catch is three levels above, you must
declare that exception in the signature of each method
between you and the catch. This means that a change at a low
level of the software can force signature changes on many
higher levels."
"Encapsulation is broken because all functions in the path of
a throw must know about details of that low-level exception."
About pass null
"Returning null from methods is bad, but passing null into
methods is worse. Unless you are working with an API which
expects you to pass null, you should avoid passing null in
your code whenever possible."
About clean Tests
"If you don’t keep your tests clean, you will lose them. And without
them, you lose the very thing that keeps your production code
flexible. Yes, you read that correctly. It is unit tests that keep
our code flexible, maintainable, and reusable. The reason is simple.
If you have tests, you do not fear making changes to the code!
Without tests every change is a possible bug.
What makes a clean test? Three things. Readability, readability, and
readability."
About Tests readability
"Each of the tests is clearly split into three parts. The first part
builds up the test data, the second part operates on that test data,
and the third part checks that the operation yielded the expected
results."
Yet About tests - F.I.R.S.T.
"Fast: If you don’t run them frequently, you won’t find problems early enough
to fix them easily."
"Independent: You should be able to run each test independently and run the
tests in any order you like."
"Repeatable: If your tests aren’t repeatable in any environment, then you’ll
always have an excuse for why they fail. You’ll also find yourself unable to
run the tests when the environment isn’t available."
"Self-validating: If the tests aren’t self-validating, then failure can become
subjective and running the tests can require a long manual evaluation."
"Timely: If you write tests after the production code, then you may find the
production code to be hard to test. You may decide that some production code
is too hard to test. You may not design the production code to be testable."
About classes
"So breaking a large function into many smaller
functions often gives us the opportunity to split
several smaller classes out as well. This gives our
program a much better organization and a more
transparent structure."
About duplications
"Duplication is the primary enemy of a well-designed
system. It represents additional work, additional
risk, and additional unnecessary complexity."
About writing concurrency code
"First and foremost, follow the Single Responsibility
Principle. Break your system into POJOs that separate thread-
aware code from thread-ignorant code. Make sure when you are
testing your thread-aware code, you are only testing it and
nothing else. This suggests that your thread-aware code
should be small and focused."
About refactoring
"Refactoring is a lot like solving a Rubik’s cube.
There are lots of little steps required to achieve a
large goal. Each step enables the next."
About writing Clean code
"I am not expecting you to be able to write clean and elegant
programs in one pass. If we have learned anything over the
last couple of decades, it is that programming is a craft
more than it is a science. To write clean code, you must
first write dirty code and then clean it."
O livro
Clean Code - A Handbook of Agile
Software Craftsmanship
Robert C. Martin (Uncle Bob)
Recomendações
Obrigado
Perguntas?
@aignacio83andrefontanaignacio ignacio83

More Related Content

What's hot

NESTLE: Noodle ban to Relaunch
NESTLE: Noodle ban to RelaunchNESTLE: Noodle ban to Relaunch
NESTLE: Noodle ban to RelaunchVinayak Gupta
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New FeaturesHaim Michael
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternMudasir Qazi
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot IntroductionJeevesh Pandey
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsİbrahim Kürce
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooksMaulik Shah
 
Introduction to JSX
Introduction to JSXIntroduction to JSX
Introduction to JSXMicah Wood
 
Clean code: understanding Boundaries and Unit Tests
Clean code: understanding Boundaries and Unit TestsClean code: understanding Boundaries and Unit Tests
Clean code: understanding Boundaries and Unit Testsradin reth
 
React JS & Functional Programming Principles
React JS & Functional Programming PrinciplesReact JS & Functional Programming Principles
React JS & Functional Programming PrinciplesAndrii Lundiak
 
BH Company Profile Presentation def.pptx
BH Company Profile Presentation def.pptxBH Company Profile Presentation def.pptx
BH Company Profile Presentation def.pptxFijnBedtextiel
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfKnoldus Inc.
 
Important React Hooks
Important React HooksImportant React Hooks
Important React HooksKnoldus Inc.
 

What's hot (20)

NESTLE: Noodle ban to Relaunch
NESTLE: Noodle ban to RelaunchNESTLE: Noodle ban to Relaunch
NESTLE: Noodle ban to Relaunch
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New Features
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Britannia Industries
Britannia IndustriesBritannia Industries
Britannia Industries
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Patrones Creacionales
Patrones CreacionalesPatrones Creacionales
Patrones Creacionales
 
Dependency injection ppt
Dependency injection pptDependency injection ppt
Dependency injection ppt
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIs
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Introduction to JSX
Introduction to JSXIntroduction to JSX
Introduction to JSX
 
Visitor pattern
Visitor patternVisitor pattern
Visitor pattern
 
Clean code: understanding Boundaries and Unit Tests
Clean code: understanding Boundaries and Unit TestsClean code: understanding Boundaries and Unit Tests
Clean code: understanding Boundaries and Unit Tests
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
React JS & Functional Programming Principles
React JS & Functional Programming PrinciplesReact JS & Functional Programming Principles
React JS & Functional Programming Principles
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
 
BH Company Profile Presentation def.pptx
BH Company Profile Presentation def.pptxBH Company Profile Presentation def.pptx
BH Company Profile Presentation def.pptx
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
 
Important React Hooks
Important React HooksImportant React Hooks
Important React Hooks
 
Java Annotations
Java AnnotationsJava Annotations
Java Annotations
 

Similar to Clean Code Quotes Handbook

YAGNI Principle and Clean Code
YAGNI Principle and Clean CodeYAGNI Principle and Clean Code
YAGNI Principle and Clean CodeLuan Reffatti
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean CodingMetin Ogurlu
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flexmichael.labriola
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2Knoldus Inc.
 
Selenium Design Patterns
Selenium Design PatternsSelenium Design Patterns
Selenium Design PatternsLiraz Shay
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave ImplicitMartin Odersky
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tipsBill Buchan
 
How to fix bug or defects in software
How to fix bug or defects in software How to fix bug or defects in software
How to fix bug or defects in software Rajasekar Subramanian
 
Searching for bugs in Mono: there are hundreds of them!
Searching for bugs in Mono: there are hundreds of them!Searching for bugs in Mono: there are hundreds of them!
Searching for bugs in Mono: there are hundreds of them!PVS-Studio
 
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...Applitools
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsSteven Smith
 
Look ma, No Frameworks - JBcnConf 2015
Look ma, No Frameworks - JBcnConf 2015Look ma, No Frameworks - JBcnConf 2015
Look ma, No Frameworks - JBcnConf 2015Pablo Chacin
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave ImplicitMartin Odersky
 
Most valuable software design principles
Most valuable software design principlesMost valuable software design principles
Most valuable software design principlesJeroen Hildering
 

Similar to Clean Code Quotes Handbook (20)

YAGNI Principle and Clean Code
YAGNI Principle and Clean CodeYAGNI Principle and Clean Code
YAGNI Principle and Clean Code
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2
 
Coding Standards
Coding StandardsCoding Standards
Coding Standards
 
Selenium Design Patterns
Selenium Design PatternsSelenium Design Patterns
Selenium Design Patterns
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave Implicit
 
Writing Quality Code
Writing Quality CodeWriting Quality Code
Writing Quality Code
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 
Clean code ch03
Clean code ch03Clean code ch03
Clean code ch03
 
Clean code
Clean codeClean code
Clean code
 
How to fix bug or defects in software
How to fix bug or defects in software How to fix bug or defects in software
How to fix bug or defects in software
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
 
Searching for bugs in Mono: there are hundreds of them!
Searching for bugs in Mono: there are hundreds of them!Searching for bugs in Mono: there are hundreds of them!
Searching for bugs in Mono: there are hundreds of them!
 
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
 
Look ma, No Frameworks - JBcnConf 2015
Look ma, No Frameworks - JBcnConf 2015Look ma, No Frameworks - JBcnConf 2015
Look ma, No Frameworks - JBcnConf 2015
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave Implicit
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Most valuable software design principles
Most valuable software design principlesMost valuable software design principles
Most valuable software design principles
 

Recently uploaded

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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...
 

Clean Code Quotes Handbook

  • 1. Clean Code Quotes A Handbook of Agile Software Craftsmanship Citações e Provocações
  • 2. Sobre mim ● Java desde 2006 (1.4) ● Spring Framework desde 2008 (2.5) ● Ritmista da Mocidade Alegre desde 2000 @aignacio83 andrefontanaignacio ignacio83
  • 3. Robert C. Martin - Uncle Bob Robert Cecil Martin é um engenheiro de software desde 1970. Ele editou e escreveu diversos livros. É co-autor do Manifesto Ágil. Também é editor chefe na revista C++ Report e serviu para o primeiro presidente da aliança ágil.
  • 4. About bad code "Nothing has a more profound and long-term degrading effect upon a development project than bad code. Bad schedules can be redone, bad requirements can be redefined. Bad team dynamics can be repaired. But bad code rots and ferments, becoming an inexorable weight that drags the team down."
  • 5. About Learn to write Clean code "You must practice it yourself, and watch yourself fail. You must watch others practice it and fail. You must see them stumble and retrace their steps. You must see them agonize over decisions and see the price they pay for making those decisions the wrong way."
  • 6. About managers "If I don’t do what my manager says, I’ll be fired. Probably not. Most managers want the truth, even when they don’t act like it. Most managers want good code, even when they are obsessing about the schedule." "They may defend the schedule and requirements with passion; but that’s their job."
  • 7. About unit tests "Code, without tests, is not clean. No matter how elegant it is, no matter how readable and accessible, if it hath not tests, it be unclean."
  • 8. About naming things "The name of a variable, function, or class, should answer all the big questions. It should tell you why it exists, what it does, and how it is used. If a name requires a comment, then the name does not reveal its intent."
  • 9. About naming things - Refactor time
  • 10. About functions "Functions should do one thing. They should do It well. They should do It only." The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that.
  • 11. About naming functions "Don’t be afraid to make a name long. A long descriptive name is better than a short enigmatic name. A long descriptive name is better than a long descriptive comment."
  • 12. About comments "The proper use of comments is to compensate for our failure to express ourself in code. Note that I used the word failure. I meant it. Comments are always failures. We must have them because we cannot always figure out how to express ourselves without them, but their use is not a cause for celebration."
  • 13. About comments - Refactor time
  • 14. About comments and Bad code "We write a module and we know it is confusing and disorganized. We know it’s a mess. So we say to ourselves, “Ooh, I’d better comment that!” No! You’d better clean it!"
  • 15. About source of truth "Truth can only be found in one place: the code. Only the code can truly tell you what it does. It is the only source of truly accurate information. Therefore, though comments are sometimes necessary, we will expend significant energy to minimize them."
  • 16. About Switchs "By their nature, switch statements always do N things. Unfortunately we can’t always avoid switch statements, but we can make sure that each switch statement is buried in a low- level class and is never repeated. We do this, of course, with polymorphism."
  • 17. About Switchs - Close Looking "There are several problems with this function. First, it’s large, and when new employee types are added, it will grow. Second, it very clearly does more than one thing. Third, it violates the Single Responsibility Principle because there is more than one reason for it to change. Fourth, it violates the Open Closed Principle (OCP) because it must change whenever new types are added. But possibly the worst problem with this function is that there are an unlimited number of other functions that will have the same structure."
  • 18. About Switchs - Refactor time
  • 19. About variables declaration "Variables should be declared as close to their usage as possible."
  • 20. About dependent functions "If one function calls another, they should be vertically close, and the caller should be above the callee, if at all possible. This gives the program a natural flow."
  • 21. About encapsulation "There is a reason that we keep our variables private. We don’t want anyone else to depend on them. We want to keep the freedom to change their type or implementation impulse. Why, then, do so many programmers automatically add getters and setters to their objects, exposing their private variables as if they were public?"
  • 22. About Data Structures and Objects "Objects hide their data behind abstractions and expose functions that operate on that data. Data structure expose their data and have no meaningful functions."
  • 23. About Data Structures and Objects - Refactor time
  • 24. About Procedural code and OO "Procedural code (code using data structures) makes it easy to add new functions without changing the existing data structures. OO code, on the other hand, makes it easy to add new classes without changing existing functions. The complement is also true: Procedural code makes it hard to add new data structures because all the functions must change. OO code makes it hard to add new functions because all the classes must change."
  • 25. About Train Wreck "This kind of code is often called a train wreck because it look like a bunch of coupled train cars. Chains of calls like this are generally considered to be sloppy style and should be avoided. It is usually best to split them up as follows:" Options opts = ctxt.getOptions(); File scratchDir = opts.getScratchDir(); String outputDir = scratchDir.getAbsolutePath(); final String outputDir = ctxt.getOptions().getScratchDir().getAbsolutePath();
  • 26. About Checked Exceptions "The price of checked exceptions is an Open/Closed Principle violation. If you throw a checked exception from a method in your code and the catch is three levels above, you must declare that exception in the signature of each method between you and the catch. This means that a change at a low level of the software can force signature changes on many higher levels." "Encapsulation is broken because all functions in the path of a throw must know about details of that low-level exception."
  • 27. About pass null "Returning null from methods is bad, but passing null into methods is worse. Unless you are working with an API which expects you to pass null, you should avoid passing null in your code whenever possible."
  • 28. About clean Tests "If you don’t keep your tests clean, you will lose them. And without them, you lose the very thing that keeps your production code flexible. Yes, you read that correctly. It is unit tests that keep our code flexible, maintainable, and reusable. The reason is simple. If you have tests, you do not fear making changes to the code! Without tests every change is a possible bug. What makes a clean test? Three things. Readability, readability, and readability."
  • 29. About Tests readability "Each of the tests is clearly split into three parts. The first part builds up the test data, the second part operates on that test data, and the third part checks that the operation yielded the expected results."
  • 30. Yet About tests - F.I.R.S.T. "Fast: If you don’t run them frequently, you won’t find problems early enough to fix them easily." "Independent: You should be able to run each test independently and run the tests in any order you like." "Repeatable: If your tests aren’t repeatable in any environment, then you’ll always have an excuse for why they fail. You’ll also find yourself unable to run the tests when the environment isn’t available." "Self-validating: If the tests aren’t self-validating, then failure can become subjective and running the tests can require a long manual evaluation." "Timely: If you write tests after the production code, then you may find the production code to be hard to test. You may decide that some production code is too hard to test. You may not design the production code to be testable."
  • 31. About classes "So breaking a large function into many smaller functions often gives us the opportunity to split several smaller classes out as well. This gives our program a much better organization and a more transparent structure."
  • 32. About duplications "Duplication is the primary enemy of a well-designed system. It represents additional work, additional risk, and additional unnecessary complexity."
  • 33. About writing concurrency code "First and foremost, follow the Single Responsibility Principle. Break your system into POJOs that separate thread- aware code from thread-ignorant code. Make sure when you are testing your thread-aware code, you are only testing it and nothing else. This suggests that your thread-aware code should be small and focused."
  • 34. About refactoring "Refactoring is a lot like solving a Rubik’s cube. There are lots of little steps required to achieve a large goal. Each step enables the next."
  • 35. About writing Clean code "I am not expecting you to be able to write clean and elegant programs in one pass. If we have learned anything over the last couple of decades, it is that programming is a craft more than it is a science. To write clean code, you must first write dirty code and then clean it."
  • 36. O livro Clean Code - A Handbook of Agile Software Craftsmanship Robert C. Martin (Uncle Bob)
  • 38.