SlideShare a Scribd company logo
YAGNI
You Ain’t Gonna Need It
YAGNI
YAGNI = You Ain’t Gonna Need It
Emerged as one of the key principles of Extreme Programming
“Always implement things when you actually need them, never when you just think that
you may need them”
Do the Simplest Thing That Could Possibly Work
YAGNI
Reasons why this principle exists:
● Prevents waste of time with unnecessary work
● Improves the developer productivity and product simplicity
● Remember: features are expensive, both to develop and maintain
● Product changes requirements, all the time!
YAGNI
“Every line of code we don’t write is dollars we didn’t spend, and time on the calendar
we get back for free.” – Tim Evans-Ariyeh
“The cheapest, fastest, and most reliable components of a computer system are those
that aren’t there.” – Gordon Bell
YAGNI
The cost of build: all the effort spent on analyzing, programming, and testing this now
useless feature.
● More code to compile
● More code to maintain
● More chances to cause bugs
● Confuse developers. What’s this code for?
YAGNI
The common reason why people build presumptive features is because they think it will
be cheaper to build it now rather than build it later.
Cost of delay: put a full storm risks feature into production and be generating revenue
only months earlier.
cost of carry: the presumptive feature adds some complexity to the software, this
complexity makes it harder to modify and debug that software, thus increasing the cost
of other features.
YAGNI
Yagni is only a viable strategy if the code is easy to change, so expending effort on
refactoring isn't a violation of yagni because refactoring makes the code more
malleable.
It actually requires malleable code.
Clean Code
Clean Code
Code that is easy to understand and easy to change
It is not enough for code to work!
"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand."
- Martin Fowler
Robert C. Martin
Clean code
“You should name a variable using the same care with which you name a first-born
child.”
“It is not the language that makes programs appear simple. It is the programmer that
make the language appear simple!”
“Of course bad code can be cleaned up. But it’s very expensive.”
“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”
“If you're good at the debugger it means you spent a lot of time debugging. I don't want
you to be good at the debugger.”
Robert C. Martin
Clean code - Meaningful Names
Variables
int count; // elapsed time in days;
int = elapsedTimeInDays;
Classes
Represent "things" - should be nouns, avoid verbs
For example: Customer, WikiPage, Account, and AddressParser
Methods
Do things - should have verb or verb phrase names
For example: convert(), delete(), or save().
Clean code - Arguments
A function shouldn’t have more than 3 arguments. Keep it as low as possible.
How to solve it?
When a function seems to need more than two or three arguments, it is likely that some
of those arguments ought to be wrapped into a class of their own.
Reducing the number of arguments by creating objects out of them may seem like
cheating, but it’s not.
Clean code - Methods or functions
“The first rule of functions is that they should be small. The second rule of functions is
that they should be smaller than that” - Robert Martin
Do one thing!
● Methods should not have more than an average of 20 code lines
● If needed, extract it to another method with a proper name that does a single thing
It's always better read one method containing 20 lines calling 10 different methods,
than method containing 400 lines unnamed logic and twisted commentary.
Clean code - Classes
Rather than count lines, count responsibilities - Single Responsibility Principle
Many small classes is better
Large, multipurpose classes force us to scroll through code that we don’t need to know
about right now.
OCP, Open Close Principle
Classes should be open for extension but closed for modifications
Ideally, we add new functionality by extending the system, not modifying the existing code.
Clean code - Classes
Classes should have a small number of instance variables
High cohesion is when you have a class that does a well defined job. Low cohesion is when a class does a lot of
jobs that don't have much in common.
Methods should affect as many variables in the class as possible to achieve “high
cohesion”
When variables aren’t used by many methods, those are probably begging for a new
class
When classes lose cohesion, it’s time to split them up.
Clean code - DRY principle
Dont Repeat Yourself (DRY)
Write Every Time (WET)
The biggest benefit of using DRY is maintainability.
● Readability
● Reuse
● Cost
● Testing
Clean code - Comments
If you are writing comments to prove your point, you are doing mistake!
Our code should explain everything. Be DRY
Correct naming can prevent comments.
Comments tend to be obsolete
*Legal and copyright comments are a different situation, they are necessary
Conclusion
Clean code means benefits: pleasant work, less stress, unit tests, easy debugging
and better quality.
You are reducing the cost of maintenance of the application you are writing.
You are making it easier to estimate the time needed for new features.
You are making it easier to fix bugs.
Essentially you are making the life easier for everyone involved in the project.
Thank you!
luanmalaguti@gmail.com
www.linkedin.com/in/luanmalaguti
Luan Malaguti Reffatti
Java Developer

More Related Content

What's hot

Extreme programming
Extreme programmingExtreme programming
Extreme programming
Chuu Htet Naing
 
15 puzzle problem game on android
15 puzzle problem game on android15 puzzle problem game on android
15 puzzle problem game on android
Akhilesh Jain
 
Agile Fundamentals
Agile FundamentalsAgile Fundamentals
Agile Fundamentals
Atlassian
 
Usability of web application
Usability of web applicationUsability of web application
Usability of web application
Burhan Ahmed
 
The design of everyday things
The design of everyday thingsThe design of everyday things
The design of everyday thingsProvaAkter
 
Introduction to Go programming
Introduction to Go programmingIntroduction to Go programming
Introduction to Go programming
Exotel
 
Intro to programming and how to start that career
Intro to programming and how to start that careerIntro to programming and how to start that career
Intro to programming and how to start that career
Tarek Alabd
 
Getting Started with ChatGPT.pdf
Getting Started with ChatGPT.pdfGetting Started with ChatGPT.pdf
Getting Started with ChatGPT.pdf
Manish Chopra
 
[DSC Europe 23] Spela Poklukar & Tea Brasanac - Retrieval Augmented Generation
[DSC Europe 23] Spela Poklukar & Tea Brasanac - Retrieval Augmented Generation[DSC Europe 23] Spela Poklukar & Tea Brasanac - Retrieval Augmented Generation
[DSC Europe 23] Spela Poklukar & Tea Brasanac - Retrieval Augmented Generation
DataScienceConferenc1
 
Agile
AgileAgile
Agile
Komal2525
 
Agile Release & Iteration Planning
Agile Release & Iteration Planning   Agile Release & Iteration Planning
Agile Release & Iteration Planning
Intelliware Development Inc.
 
Lego4scrum at Dashlane
Lego4scrum at DashlaneLego4scrum at Dashlane
Lego4scrum at Dashlane
Frédéric Rivain
 
Computational thinking
Computational thinkingComputational thinking
Computational thinking
Jackson Kuo
 
Agile Engineering Practices
Agile Engineering PracticesAgile Engineering Practices
Agile Engineering Practices
Vernon Stinebaker
 
Agile Scrum Training Process
Agile Scrum Training ProcessAgile Scrum Training Process
Agile Scrum Training Process
Clarion Marketing
 
Prototyping
PrototypingPrototyping
Prototyping
Eman Abed AlWahhab
 
Lecture 5: Human-Computer Interaction Course (2015) @VU University Amsterdam
Lecture 5: Human-Computer Interaction Course (2015) @VU University AmsterdamLecture 5: Human-Computer Interaction Course (2015) @VU University Amsterdam
Lecture 5: Human-Computer Interaction Course (2015) @VU University Amsterdam
Lora Aroyo
 
외계어 스터디 1/5 - Overview
외계어 스터디 1/5 - Overview외계어 스터디 1/5 - Overview
외계어 스터디 1/5 - Overview민태 김
 
Interaction Design
Interaction DesignInteraction Design
Interaction Design
Kajsa Gren
 
User Interface Prototyping - Low- and High-Fidelity Prototyping Today
User Interface Prototyping - Low- and High-Fidelity Prototyping TodayUser Interface Prototyping - Low- and High-Fidelity Prototyping Today
User Interface Prototyping - Low- and High-Fidelity Prototyping Today
Thomas Memmel
 

What's hot (20)

Extreme programming
Extreme programmingExtreme programming
Extreme programming
 
15 puzzle problem game on android
15 puzzle problem game on android15 puzzle problem game on android
15 puzzle problem game on android
 
Agile Fundamentals
Agile FundamentalsAgile Fundamentals
Agile Fundamentals
 
Usability of web application
Usability of web applicationUsability of web application
Usability of web application
 
The design of everyday things
The design of everyday thingsThe design of everyday things
The design of everyday things
 
Introduction to Go programming
Introduction to Go programmingIntroduction to Go programming
Introduction to Go programming
 
Intro to programming and how to start that career
Intro to programming and how to start that careerIntro to programming and how to start that career
Intro to programming and how to start that career
 
Getting Started with ChatGPT.pdf
Getting Started with ChatGPT.pdfGetting Started with ChatGPT.pdf
Getting Started with ChatGPT.pdf
 
[DSC Europe 23] Spela Poklukar & Tea Brasanac - Retrieval Augmented Generation
[DSC Europe 23] Spela Poklukar & Tea Brasanac - Retrieval Augmented Generation[DSC Europe 23] Spela Poklukar & Tea Brasanac - Retrieval Augmented Generation
[DSC Europe 23] Spela Poklukar & Tea Brasanac - Retrieval Augmented Generation
 
Agile
AgileAgile
Agile
 
Agile Release & Iteration Planning
Agile Release & Iteration Planning   Agile Release & Iteration Planning
Agile Release & Iteration Planning
 
Lego4scrum at Dashlane
Lego4scrum at DashlaneLego4scrum at Dashlane
Lego4scrum at Dashlane
 
Computational thinking
Computational thinkingComputational thinking
Computational thinking
 
Agile Engineering Practices
Agile Engineering PracticesAgile Engineering Practices
Agile Engineering Practices
 
Agile Scrum Training Process
Agile Scrum Training ProcessAgile Scrum Training Process
Agile Scrum Training Process
 
Prototyping
PrototypingPrototyping
Prototyping
 
Lecture 5: Human-Computer Interaction Course (2015) @VU University Amsterdam
Lecture 5: Human-Computer Interaction Course (2015) @VU University AmsterdamLecture 5: Human-Computer Interaction Course (2015) @VU University Amsterdam
Lecture 5: Human-Computer Interaction Course (2015) @VU University Amsterdam
 
외계어 스터디 1/5 - Overview
외계어 스터디 1/5 - Overview외계어 스터디 1/5 - Overview
외계어 스터디 1/5 - Overview
 
Interaction Design
Interaction DesignInteraction Design
Interaction Design
 
User Interface Prototyping - Low- and High-Fidelity Prototyping Today
User Interface Prototyping - Low- and High-Fidelity Prototyping TodayUser Interface Prototyping - Low- and High-Fidelity Prototyping Today
User Interface Prototyping - Low- and High-Fidelity Prototyping Today
 

Similar to YAGNI Principle and Clean Code

[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
DevDay.org
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2
Knoldus Inc.
 
Clean code quotes - Citações e provocações
Clean code quotes - Citações e provocaçõesClean code quotes - Citações e provocações
Clean code quotes - Citações e provocações
André de Fontana Ignacio
 
Most valuable software design principles
Most valuable software design principlesMost valuable software design principles
Most valuable software design principles
Jeroen Hildering
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
Kevlin Henney
 
Clean code
Clean codeClean code
Clean code
Simon Sönnby
 
WordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressWordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPress
mtoppa
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
Metin Ogurlu
 
Best pratice
Best praticeBest pratice
Best pratice
Eugenio Romano
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tipsBill Buchan
 
The View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tipsThe View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tipsBill Buchan
 
The View - Lotusscript coding best practices
The View - Lotusscript coding best practicesThe View - Lotusscript coding best practices
The View - Lotusscript coding best practicesBill Buchan
 
Software Development Essential Skills
Software Development Essential SkillsSoftware Development Essential Skills
Software Development Essential SkillsJohn Choi
 
9-Coding.ppt
9-Coding.ppt9-Coding.ppt
9-Coding.ppt
KomalSinghGill
 
Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Edition
jexp
 
Managing and evolving JavaScript Code
Managing and evolving JavaScript CodeManaging and evolving JavaScript Code
Managing and evolving JavaScript Code
Jean Carlo Emer
 
Clean Code Software Engineering
Clean Code Software Engineering Clean Code Software Engineering
Clean Code Software Engineering
Inocentshuja Ahmad
 
Are You a SOLID Coder?
Are You a SOLID Coder?Are You a SOLID Coder?
Are You a SOLID Coder?
Steve Green
 

Similar to YAGNI Principle and Clean Code (20)

[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2
 
Clean code quotes - Citações e provocações
Clean code quotes - Citações e provocaçõesClean code quotes - Citações e provocações
Clean code quotes - Citações e provocações
 
Most valuable software design principles
Most valuable software design principlesMost valuable software design principles
Most valuable software design principles
 
Code quality
Code quality Code quality
Code quality
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
 
Clean code
Clean codeClean code
Clean code
 
Coding Standards
Coding StandardsCoding Standards
Coding Standards
 
WordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressWordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPress
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
 
Best pratice
Best praticeBest pratice
Best pratice
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 
The View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tipsThe View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tips
 
The View - Lotusscript coding best practices
The View - Lotusscript coding best practicesThe View - Lotusscript coding best practices
The View - Lotusscript coding best practices
 
Software Development Essential Skills
Software Development Essential SkillsSoftware Development Essential Skills
Software Development Essential Skills
 
9-Coding.ppt
9-Coding.ppt9-Coding.ppt
9-Coding.ppt
 
Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Edition
 
Managing and evolving JavaScript Code
Managing and evolving JavaScript CodeManaging and evolving JavaScript Code
Managing and evolving JavaScript Code
 
Clean Code Software Engineering
Clean Code Software Engineering Clean Code Software Engineering
Clean Code Software Engineering
 
Are You a SOLID Coder?
Are You a SOLID Coder?Are You a SOLID Coder?
Are You a SOLID Coder?
 

Recently uploaded

Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 

Recently uploaded (20)

Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 

YAGNI Principle and Clean Code

  • 2. YAGNI YAGNI = You Ain’t Gonna Need It Emerged as one of the key principles of Extreme Programming “Always implement things when you actually need them, never when you just think that you may need them” Do the Simplest Thing That Could Possibly Work
  • 3.
  • 4. YAGNI Reasons why this principle exists: ● Prevents waste of time with unnecessary work ● Improves the developer productivity and product simplicity ● Remember: features are expensive, both to develop and maintain ● Product changes requirements, all the time!
  • 5. YAGNI “Every line of code we don’t write is dollars we didn’t spend, and time on the calendar we get back for free.” – Tim Evans-Ariyeh “The cheapest, fastest, and most reliable components of a computer system are those that aren’t there.” – Gordon Bell
  • 6. YAGNI The cost of build: all the effort spent on analyzing, programming, and testing this now useless feature. ● More code to compile ● More code to maintain ● More chances to cause bugs ● Confuse developers. What’s this code for?
  • 7. YAGNI The common reason why people build presumptive features is because they think it will be cheaper to build it now rather than build it later. Cost of delay: put a full storm risks feature into production and be generating revenue only months earlier. cost of carry: the presumptive feature adds some complexity to the software, this complexity makes it harder to modify and debug that software, thus increasing the cost of other features.
  • 8. YAGNI Yagni is only a viable strategy if the code is easy to change, so expending effort on refactoring isn't a violation of yagni because refactoring makes the code more malleable. It actually requires malleable code.
  • 10. Clean Code Code that is easy to understand and easy to change It is not enough for code to work! "Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - Martin Fowler
  • 12. Clean code “You should name a variable using the same care with which you name a first-born child.” “It is not the language that makes programs appear simple. It is the programmer that make the language appear simple!” “Of course bad code can be cleaned up. But it’s very expensive.” “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” “If you're good at the debugger it means you spent a lot of time debugging. I don't want you to be good at the debugger.” Robert C. Martin
  • 13. Clean code - Meaningful Names Variables int count; // elapsed time in days; int = elapsedTimeInDays; Classes Represent "things" - should be nouns, avoid verbs For example: Customer, WikiPage, Account, and AddressParser Methods Do things - should have verb or verb phrase names For example: convert(), delete(), or save().
  • 14. Clean code - Arguments A function shouldn’t have more than 3 arguments. Keep it as low as possible. How to solve it? When a function seems to need more than two or three arguments, it is likely that some of those arguments ought to be wrapped into a class of their own. Reducing the number of arguments by creating objects out of them may seem like cheating, but it’s not.
  • 15. Clean code - Methods or functions “The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that” - Robert Martin Do one thing! ● Methods should not have more than an average of 20 code lines ● If needed, extract it to another method with a proper name that does a single thing It's always better read one method containing 20 lines calling 10 different methods, than method containing 400 lines unnamed logic and twisted commentary.
  • 16. Clean code - Classes Rather than count lines, count responsibilities - Single Responsibility Principle Many small classes is better Large, multipurpose classes force us to scroll through code that we don’t need to know about right now. OCP, Open Close Principle Classes should be open for extension but closed for modifications Ideally, we add new functionality by extending the system, not modifying the existing code.
  • 17. Clean code - Classes Classes should have a small number of instance variables High cohesion is when you have a class that does a well defined job. Low cohesion is when a class does a lot of jobs that don't have much in common. Methods should affect as many variables in the class as possible to achieve “high cohesion” When variables aren’t used by many methods, those are probably begging for a new class When classes lose cohesion, it’s time to split them up.
  • 18. Clean code - DRY principle Dont Repeat Yourself (DRY) Write Every Time (WET) The biggest benefit of using DRY is maintainability. ● Readability ● Reuse ● Cost ● Testing
  • 19. Clean code - Comments If you are writing comments to prove your point, you are doing mistake! Our code should explain everything. Be DRY Correct naming can prevent comments. Comments tend to be obsolete *Legal and copyright comments are a different situation, they are necessary
  • 20. Conclusion Clean code means benefits: pleasant work, less stress, unit tests, easy debugging and better quality. You are reducing the cost of maintenance of the application you are writing. You are making it easier to estimate the time needed for new features. You are making it easier to fix bugs. Essentially you are making the life easier for everyone involved in the project.