SlideShare a Scribd company logo
1 of 74
Download to read offline
Understanding

Refactoring
Bryan Beecham

@BillyGarnet

bryan@industriallogic.com
Writing Healthy Code
@BillyGarnet
Is software designed to be simple and elegant more valuable

than software that is complex and hard to maintain?
@BillyGarnet
~9600 line vb class named frm2
Continuous Improvement
Simplicity
@BillyGarnet
“Simplicity is the only thing that really scales.”
–Joshua Kerievsky
@BillyGarnet
Modern Agile
Make People Awesome

Make Safety a Prerequisite

Experiment and Learn Rapidly

Deliver Value Continuously
@BillyGarnet
Refactoring
Improving the design of existing code
@BillyGarnet
“Refactoring is the process of changing a software system
in such a way that it does not alter the external behaviour
of the code yet improves its internal structure.”
–Martin Fowler
@BillyGarnet
It must work.
It must be understandable.
It must be updatable.
Needs of Software
What should software do?
Reasons to extract a function
✤ To reuse it (the only reason some consider).
✤ To name it’s operation.
✤ To make it testable.
✤ To get it out of your way so you can see the code that called it more clearly.
@BillyGarnet
Remove the Clutter.
Remove the Complexity.
Remove the Cleverness.
Three Cs
@BillyGarnet
Duplication
Duplication
Duplication
Three Ds
@BillyGarnet
Ring of Fire
Johnny Cash
@BillyGarnet
➤ Love is a burnin' thing,
➤ And it makes a fiery ring
➤ Bound by wild desire
➤ I fell into a ring of fire.
➤ I fell into a burnin' ring of
fire
➤ I went down, down, down
➤ And the flames went higher,
➤ And it burns, burns, burns,
➤ The ring of fire, the ring of
fire.
➤ I fell into a burnin' ring of
fire
➤ I went down, down, down
➤ And the flames went higher,
➤ And it burns, burns, burns,
➤ The ring of fire, the ring of
fire.
➤ The taste of love is sweet
➤ When hearts like ours meet.
➤ I fell for you like a child
➤ Oh, but the fire went wild.
➤ I fell into a burnin' ring of fire
➤ I went down, down, down
➤ And the flames went higher,
➤ And it burns, burns, burns,
➤ The ring of fire, the ring of fire.
➤ I fell into a burnin' ring of fire
➤ I went down, down, down,
➤ And the flames went higher,
➤ And it burns, burns, burns,
➤ The ring of fire, the ring of fire.
➤ And it burns, burns, burns,
➤ The ring of fire, the ring of fire.
➤ The ring of fire, the ring of fire
➤ The ring of fire
@BillyGarnet
Love is a burnin' thing,
And it makes a fiery ring
Bound by wild desire
I fell into a ring of fire.
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of
fire.
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of fire.
The taste of love is sweet
When hearts like ours meet.
I fell for you like a child
Oh, but the fire went wild.
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of fire.
I fell into a burnin' ring of fire
I went down, down, down,
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of fire.
And it burns, burns, burns,
The ring of fire, the ring of fire.
The ring of fire, the ring of fire
The ring of fire
@BillyGarnet
Love is a burnin' thing,
And it makes a fiery ring
Bound by wild desire
I fell into a ring of fire.
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of
fire.
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of
fire.
The taste of love is sweet
When hearts like ours meet.
I fell for you like a child
Oh, but the fire went wild.
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of fire.
I fell into a burnin' ring of fire
I went down, down, down,
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of fire.
And it burns, burns, burns,
The ring of fire, the ring of fire.
The ring of fire, the ring of fire
The ring of fire
@BillyGarnet
Love is a burnin' thing,
And it makes a fiery ring
Bound by wild desire
I fell into a ring of fire.


(CHORUS)
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of
fire.
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of
fire.
The taste of love is sweet
When hearts like ours meet.
I fell for you like a child
Oh, but the fire went wild.
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of fire.
I fell into a burnin' ring of fire
I went down, down, down,
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of fire.
And it burns, burns, burns,
The ring of fire, the ring of fire.
The ring of fire, the ring of fire
The ring of fire
@BillyGarnet
Love is a burnin' thing,
And it makes a fiery ring
Bound by wild desire
I fell into a ring of fire.


(CHORUS)
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of fire.
CHORUS
The taste of love is sweet
When hearts like ours meet.
I fell for you like a child
Oh, but the fire went wild.
CHORUS
CHORUS
And it burns, burns, burns,
The ring of fire, the ring of
fire.
The ring of fire, the ring of
fire
The ring of fire
@BillyGarnet
(CHORUS)
I fell into a burnin' ring of fire
I went down, down, down
And the flames went higher,
And it burns, burns, burns,
The ring of fire, the ring of fire.
The taste of love is sweet
When hearts like ours meet.
I fell for you like a child
Oh, but the fire went wild.
And it burns, burns, burns,
The ring of fire, the ring of fire.
The ring of fire, the ring of fire
The ring of fire
Love is a burnin' thing,
And it makes a fiery ring
Bound by wild desire
I fell into a ring of fire.
CHORUS
CHORUS
@BillyGarnet
Wow!
That’s much easier to read
@BillyGarnet
Why Refactor?
Development slows over time
@BillyGarnet
Return on Investment (ROI)
@BillyGarnet
How many people have been on a project where
the requirements didn’t change?
@BillyGarnet
Quotes
From some people I like…
@BillyGarnet
“It seems that perfection is attained
not when there is nothing more to add,
but when there is nothing more to remove.”
–Antoine de Saint Exupéry
@BillyGarnet
“Refactoring ought to be invisible. 

It should be part of every task, and not a task on its own.”
~Tim Ottinger
@BillyGarnet
“It (refactoring) is the cheapest and safest way to read code. It is also the only way
to safely change untestable code so that you can then start wrapping it in tests.”
~Arlo Belshee
@BillyGarnet
“ Getting an app to work is the app-titude test for a programmer.

There is a lot more to programming than just getting your app to work”
~James Grenning
@BillyGarnet
“Refactoring can be done in smaller steps than you think it can,
never breaking the program.”
~Ron Jeffries
@BillyGarnet
“Relentless refactoring is the single best thing you 

can do to fix and avoid technical debt”
~Declan Whelan
@BillyGarnet
“I refactor for one reason: to reduce volatility in the marginal cost of features.”
~J.B. Rainsberger
@BillyGarnet
“Refactoring is like breathing. You should do it all of the
time without giving it much thought.”
~Jeff ‘Cheezy’ Morgan
@BillyGarnet
“We refactor to embrace change.”
~Bryan Beecham
@BillyGarnet
“You have two options, you can refactor, or you can build a big ball of mud.”
~Chet Hendrickson
@BillyGarnet
“For each desired change, make the change easy (warning: this may be hard), 

then make the easy change.”
~Kent Beck
@BillyGarnet
“If you’re a little better each day, next year you’ll be great.

If you’re a little worse each day, next year you’ll be horrible.”
~Llewellyn Falco
@BillyGarnet
“Imagine how good a bowler you could be if you could adjust the direction of the
ball once it's left your hands. Refactoring is what does that for us in writing code.”
~Woody Zuill
@BillyGarnet
“Business is well served by continuous refactoring, yet the practice of refactoring
must co-exist harmoniously with business priorities.”
~Joshua Kerievsky
@BillyGarnet
“Refactoring, above all else, is a tool for managing risk.”
~Amitai Schlair
@BillyGarnet
“To me, refactoring is the most pleasant part of programming.

I find it meditative and soothing, to change my code and my design
until it can be grasped almost instantly.”
~Mike ‘GeePaw’ Hill
@BillyGarnet
“Rename class is the most powerful refactoring.”
~Michael Feathers
@BillyGarnet
“The way to arrest entropy in software is to refactor it.”
~Joseph Yoder
@BillyGarnet
“So if you want to go fast, if you want to get done quickly, 

if you want your code to be easy to write, make it easy to read.”
~Uncle Bob Martin
@BillyGarnet
HumanRefactoring
Get up! Get on up!
Inside Refactoring
@BillyGarnet
Inside Refactoring
Prepare
Improve
Clean
Prepare
✤ Prepare has also been referred to as nesting, making room, prefactoring or
rough-in. We make small changes to the code so the improvement can take
place.
Improve
✤ Improve is when we make an improvement to the code without changing
its external behaviour.
Clean
✤ Clean is when we remove code we have made unnecessary and put the
code back in a state to start something new.
✤ At this point we are done refactoring and can run tests, and, assuming they
pass, integrate this refactoring.
Make a sandwich
✤ Get out all the things you need
✤ Assemble the sandwich
✤ Put everything away
Working Effectively with Legacy Code
✤ 1. Identify the code you want to extract and comment it out.
✤ 2. Think of a new name for a method and create it as an empty method.
✤ 3. Place a call to the new method in the old method.
✤ 4. Copy the code you want to extract into the new method.
✤ 5. Lean on the Compiler to find out what parameters you’ll have to pass and what values you’ll have to
return.
✤ 6. Adjust the method declaration to accommodate the parameters and return value (if any).
✤ 7. Run your tests.
✤ 8. Delete your commented out code.
Prepare
✤ 1. Identify the code you want to extract and comment it out.
✤ 2. Think of a new name for a method and create it as an empty method.
✤ 3. Place a call to the new method in the old method.
Improve
✤ 4. Copy the code you want to extract into the new method.
✤ 5. Lean on the Compiler to find out what parameters you’ll have to pass
and what values you’ll have to return.
✤ 6. Adjust the method declaration to accommodate the parameters and
return value (if any).
✤ 7. Run your tests.
Clean
✤ 8. Delete your commented out code.
@BillyGarnet
Inside Refactoring
Example
@BillyGarnet
@BillyGarnet
Inside Refactoring
Prepare
Improve
Clean
@BillyGarnet
def convert(arabic):
numeral = ""
for i in range(0, arabic):
numeral += "I"
return numeral
@BillyGarnet
def convert(arabic):
numeral = ""
current_number = arabic
for i in range(0, current_number):
if current_number >= 10:
numeral += "X"
current_number -= 10
for i in range(0, current_number):
numeral += "I"
return numeral
@BillyGarnet
def convert(arabic):
numeral = ""
for i in range(0, arabic):
if arabic >= 10:
numeral += "X"
arabic -= 10
for i in range(0, arabic):
if arabic >= 1:
numeral += "I"
arabic -= 1
return numeral
@BillyGarnet
def convert(arabic):
numeral = ""
arabic_value = 10
roman_value = "X"
for i in range(0, arabic):
if arabic >= arabic_value:
numeral += roman_value
arabic -= arabic_value
arabic_value = 1
roman_value = "I"
for i in range(0, arabic):
if arabic >= arabic_value:
numeral += roman_value
arabic -= arabic_value
return numeral
@BillyGarnet
def convert(arabic):
numeral = ""
arabic_digits = [10, 1]
roman_digits = ["X", "I"]
for i in range(0, len(arabic_digits)):
while arabic >= arabic_digits[i]:
numeral += roman_digits[i]
arabic -= arabic_digits[i]
# arabic_digits = 1
# roman_digits = "I"
# for i in range(0, arabic):
# if arabic >= arabic_digits:
# numeral += roman_digits
# arabic -= arabic_digits
return numeral
@BillyGarnet
def convert(arabic):
numeral = ""
arabic_digits = [10, 1]
roman_digits = ["X", "I"]
for i in range(0, len(arabic_digits)):
while arabic >= arabic_digits[i]:
numeral += roman_digits[i]
arabic -= arabic_digits[i]
return numeral
@BillyGarnet
arabic_digits = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]

roman_digits = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
@BillyGarnet
Inside Refactoring
Prepare
Improve
Clean
Bryan Beecham

@BillyGarnet

bryan@industriallogic.com
Questions
and
Answers



Questionable Code
Clarity
if (x){ return true } else if (!x) { return false }
if (x) return true

return false
if (x){

return true
} else if (!x) { 

return false
}
return x
Clutter
;
Clutter
//
// This is cool
// I saw it on a blog and thought if we changed our code
// it could work. Call me if you need more explanation
//
//
@BillyGarnet
Books
✤ Refactoring - Martin Fowler
✤ Working Effectively with Legacy Code - Michael Feathers
✤ Refactoring to Patterns - Joshua Kerievsky
✤ Refactoring Workbook - Bill Wake
✤ Healthy Code - Getting Started with Refactoring - Bryan Beecham

More Related Content

Recently uploaded

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 

Recently uploaded (20)

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Refactoring - Agile Tech Conference 2016

  • 2. @BillyGarnet Is software designed to be simple and elegant more valuable
 than software that is complex and hard to maintain?
  • 3. @BillyGarnet ~9600 line vb class named frm2
  • 6. @BillyGarnet “Simplicity is the only thing that really scales.” –Joshua Kerievsky
  • 7. @BillyGarnet Modern Agile Make People Awesome
 Make Safety a Prerequisite
 Experiment and Learn Rapidly
 Deliver Value Continuously
  • 9. @BillyGarnet “Refactoring is the process of changing a software system in such a way that it does not alter the external behaviour of the code yet improves its internal structure.” –Martin Fowler
  • 10. @BillyGarnet It must work. It must be understandable. It must be updatable. Needs of Software What should software do?
  • 11. Reasons to extract a function ✤ To reuse it (the only reason some consider). ✤ To name it’s operation. ✤ To make it testable. ✤ To get it out of your way so you can see the code that called it more clearly.
  • 12. @BillyGarnet Remove the Clutter. Remove the Complexity. Remove the Cleverness. Three Cs
  • 15. @BillyGarnet ➤ Love is a burnin' thing, ➤ And it makes a fiery ring ➤ Bound by wild desire ➤ I fell into a ring of fire. ➤ I fell into a burnin' ring of fire ➤ I went down, down, down ➤ And the flames went higher, ➤ And it burns, burns, burns, ➤ The ring of fire, the ring of fire. ➤ I fell into a burnin' ring of fire ➤ I went down, down, down ➤ And the flames went higher, ➤ And it burns, burns, burns, ➤ The ring of fire, the ring of fire. ➤ The taste of love is sweet ➤ When hearts like ours meet. ➤ I fell for you like a child ➤ Oh, but the fire went wild. ➤ I fell into a burnin' ring of fire ➤ I went down, down, down ➤ And the flames went higher, ➤ And it burns, burns, burns, ➤ The ring of fire, the ring of fire. ➤ I fell into a burnin' ring of fire ➤ I went down, down, down, ➤ And the flames went higher, ➤ And it burns, burns, burns, ➤ The ring of fire, the ring of fire. ➤ And it burns, burns, burns, ➤ The ring of fire, the ring of fire. ➤ The ring of fire, the ring of fire ➤ The ring of fire
  • 16. @BillyGarnet Love is a burnin' thing, And it makes a fiery ring Bound by wild desire I fell into a ring of fire. I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. The taste of love is sweet When hearts like ours meet. I fell for you like a child Oh, but the fire went wild. I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. I fell into a burnin' ring of fire I went down, down, down, And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. And it burns, burns, burns, The ring of fire, the ring of fire. The ring of fire, the ring of fire The ring of fire
  • 17. @BillyGarnet Love is a burnin' thing, And it makes a fiery ring Bound by wild desire I fell into a ring of fire. I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. The taste of love is sweet When hearts like ours meet. I fell for you like a child Oh, but the fire went wild. I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. I fell into a burnin' ring of fire I went down, down, down, And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. And it burns, burns, burns, The ring of fire, the ring of fire. The ring of fire, the ring of fire The ring of fire
  • 18. @BillyGarnet Love is a burnin' thing, And it makes a fiery ring Bound by wild desire I fell into a ring of fire. 
 (CHORUS) I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. The taste of love is sweet When hearts like ours meet. I fell for you like a child Oh, but the fire went wild. I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. I fell into a burnin' ring of fire I went down, down, down, And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. And it burns, burns, burns, The ring of fire, the ring of fire. The ring of fire, the ring of fire The ring of fire
  • 19. @BillyGarnet Love is a burnin' thing, And it makes a fiery ring Bound by wild desire I fell into a ring of fire. 
 (CHORUS) I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. CHORUS The taste of love is sweet When hearts like ours meet. I fell for you like a child Oh, but the fire went wild. CHORUS CHORUS And it burns, burns, burns, The ring of fire, the ring of fire. The ring of fire, the ring of fire The ring of fire
  • 20. @BillyGarnet (CHORUS) I fell into a burnin' ring of fire I went down, down, down And the flames went higher, And it burns, burns, burns, The ring of fire, the ring of fire. The taste of love is sweet When hearts like ours meet. I fell for you like a child Oh, but the fire went wild. And it burns, burns, burns, The ring of fire, the ring of fire. The ring of fire, the ring of fire The ring of fire Love is a burnin' thing, And it makes a fiery ring Bound by wild desire I fell into a ring of fire. CHORUS CHORUS
  • 26. @BillyGarnet How many people have been on a project where the requirements didn’t change?
  • 28. @BillyGarnet “It seems that perfection is attained not when there is nothing more to add, but when there is nothing more to remove.” –Antoine de Saint Exupéry
  • 29. @BillyGarnet “Refactoring ought to be invisible. 
 It should be part of every task, and not a task on its own.” ~Tim Ottinger
  • 30. @BillyGarnet “It (refactoring) is the cheapest and safest way to read code. It is also the only way to safely change untestable code so that you can then start wrapping it in tests.” ~Arlo Belshee
  • 31. @BillyGarnet “ Getting an app to work is the app-titude test for a programmer.
 There is a lot more to programming than just getting your app to work” ~James Grenning
  • 32. @BillyGarnet “Refactoring can be done in smaller steps than you think it can, never breaking the program.” ~Ron Jeffries
  • 33. @BillyGarnet “Relentless refactoring is the single best thing you 
 can do to fix and avoid technical debt” ~Declan Whelan
  • 34. @BillyGarnet “I refactor for one reason: to reduce volatility in the marginal cost of features.” ~J.B. Rainsberger
  • 35. @BillyGarnet “Refactoring is like breathing. You should do it all of the time without giving it much thought.” ~Jeff ‘Cheezy’ Morgan
  • 36. @BillyGarnet “We refactor to embrace change.” ~Bryan Beecham
  • 37. @BillyGarnet “You have two options, you can refactor, or you can build a big ball of mud.” ~Chet Hendrickson
  • 38. @BillyGarnet “For each desired change, make the change easy (warning: this may be hard), 
 then make the easy change.” ~Kent Beck
  • 39. @BillyGarnet “If you’re a little better each day, next year you’ll be great.
 If you’re a little worse each day, next year you’ll be horrible.” ~Llewellyn Falco
  • 40. @BillyGarnet “Imagine how good a bowler you could be if you could adjust the direction of the ball once it's left your hands. Refactoring is what does that for us in writing code.” ~Woody Zuill
  • 41. @BillyGarnet “Business is well served by continuous refactoring, yet the practice of refactoring must co-exist harmoniously with business priorities.” ~Joshua Kerievsky
  • 42. @BillyGarnet “Refactoring, above all else, is a tool for managing risk.” ~Amitai Schlair
  • 43. @BillyGarnet “To me, refactoring is the most pleasant part of programming.
 I find it meditative and soothing, to change my code and my design until it can be grasped almost instantly.” ~Mike ‘GeePaw’ Hill
  • 44. @BillyGarnet “Rename class is the most powerful refactoring.” ~Michael Feathers
  • 45. @BillyGarnet “The way to arrest entropy in software is to refactor it.” ~Joseph Yoder
  • 46. @BillyGarnet “So if you want to go fast, if you want to get done quickly, 
 if you want your code to be easy to write, make it easy to read.” ~Uncle Bob Martin
  • 50. Prepare ✤ Prepare has also been referred to as nesting, making room, prefactoring or rough-in. We make small changes to the code so the improvement can take place.
  • 51. Improve ✤ Improve is when we make an improvement to the code without changing its external behaviour.
  • 52. Clean ✤ Clean is when we remove code we have made unnecessary and put the code back in a state to start something new. ✤ At this point we are done refactoring and can run tests, and, assuming they pass, integrate this refactoring.
  • 53. Make a sandwich ✤ Get out all the things you need ✤ Assemble the sandwich ✤ Put everything away
  • 54. Working Effectively with Legacy Code ✤ 1. Identify the code you want to extract and comment it out. ✤ 2. Think of a new name for a method and create it as an empty method. ✤ 3. Place a call to the new method in the old method. ✤ 4. Copy the code you want to extract into the new method. ✤ 5. Lean on the Compiler to find out what parameters you’ll have to pass and what values you’ll have to return. ✤ 6. Adjust the method declaration to accommodate the parameters and return value (if any). ✤ 7. Run your tests. ✤ 8. Delete your commented out code.
  • 55. Prepare ✤ 1. Identify the code you want to extract and comment it out. ✤ 2. Think of a new name for a method and create it as an empty method. ✤ 3. Place a call to the new method in the old method.
  • 56. Improve ✤ 4. Copy the code you want to extract into the new method. ✤ 5. Lean on the Compiler to find out what parameters you’ll have to pass and what values you’ll have to return. ✤ 6. Adjust the method declaration to accommodate the parameters and return value (if any). ✤ 7. Run your tests.
  • 57. Clean ✤ 8. Delete your commented out code.
  • 61. @BillyGarnet def convert(arabic): numeral = "" for i in range(0, arabic): numeral += "I" return numeral
  • 62. @BillyGarnet def convert(arabic): numeral = "" current_number = arabic for i in range(0, current_number): if current_number >= 10: numeral += "X" current_number -= 10 for i in range(0, current_number): numeral += "I" return numeral
  • 63. @BillyGarnet def convert(arabic): numeral = "" for i in range(0, arabic): if arabic >= 10: numeral += "X" arabic -= 10 for i in range(0, arabic): if arabic >= 1: numeral += "I" arabic -= 1 return numeral
  • 64. @BillyGarnet def convert(arabic): numeral = "" arabic_value = 10 roman_value = "X" for i in range(0, arabic): if arabic >= arabic_value: numeral += roman_value arabic -= arabic_value arabic_value = 1 roman_value = "I" for i in range(0, arabic): if arabic >= arabic_value: numeral += roman_value arabic -= arabic_value return numeral
  • 65. @BillyGarnet def convert(arabic): numeral = "" arabic_digits = [10, 1] roman_digits = ["X", "I"] for i in range(0, len(arabic_digits)): while arabic >= arabic_digits[i]: numeral += roman_digits[i] arabic -= arabic_digits[i] # arabic_digits = 1 # roman_digits = "I" # for i in range(0, arabic): # if arabic >= arabic_digits: # numeral += roman_digits # arabic -= arabic_digits return numeral
  • 66. @BillyGarnet def convert(arabic): numeral = "" arabic_digits = [10, 1] roman_digits = ["X", "I"] for i in range(0, len(arabic_digits)): while arabic >= arabic_digits[i]: numeral += roman_digits[i] arabic -= arabic_digits[i] return numeral
  • 67. @BillyGarnet arabic_digits = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
 roman_digits = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
  • 71. Clarity if (x){ return true } else if (!x) { return false } if (x) return true
 return false if (x){
 return true } else if (!x) { 
 return false } return x
  • 73. Clutter // // This is cool // I saw it on a blog and thought if we changed our code // it could work. Call me if you need more explanation // //
  • 74. @BillyGarnet Books ✤ Refactoring - Martin Fowler ✤ Working Effectively with Legacy Code - Michael Feathers ✤ Refactoring to Patterns - Joshua Kerievsky ✤ Refactoring Workbook - Bill Wake ✤ Healthy Code - Getting Started with Refactoring - Bryan Beecham