SlideShare a Scribd company logo
1 of 42
for quality
X 2+3x+1==(x+1)(x+2)

 Improved code structure
 Same executable behavior
 Easy write, change
 Deferred complexity

 Quality

 Velocity!
 Understandable

 Predictable

 Changes   Localized
 We  dig design patterns
 We    TDD
 Incremental
 Ensure working version
 Create/Ensure tests

 Use version control
 +:Variable, Method
 ++: Class, Class Interaction
 Var rename; method
  rename; method extract
 Interface/class extract
 Safeand easy
 Limited to simple ref’
 Distinguish             Good Design
To the point   Readable       Simple

Predictable/   Modifiable     Testable
Uncoupled
 Where             to refactor first?
Point         Readable    Simple   Predictable Modify
                                   /uncoupled
Dup code      Renaming    Switch   Refused    Parallel
Large class   Long method          bequest    hierarchy
Lazy class    Large class          Feature
Speculative                        Envy
generality                         Intimacy
 Sharing

 Consuming
 Takean example of smell
 and a change
 Demo

 Identifysmells
 Propose moves
 Demo

 Identify   the qualities
 Discussion
 Minor: As you go
 Major: At mini-
  feature/class completion
 Not as a separate milestone
 Quality

 Adaptability

 Velocity   Impact?
 Refactoring projects
 Code and fix

 Performance

 Procastination
 Your ref’experience
 Favorite ref’ moves
 Hopefully,   answers
 ???
 Yaniv@YanivPessach.com
 Before and after refactoring
 Refactoring tools menus
int ProcessX(int x) { return x+1; }
Ren method



             int IncrementPosition(int x) {
               return x+1; }

             int IncrementPosition(int
  Ren var




               oldPos) { return oldPos+1; }
float Distance(float x1, float y1, float x2,
                         float y2) { return Math.Sqrt((x1 - x2) *
                         (x1 - x2) + (y1 - y2) * (y1 - y2));}
Param list to class




                       class FloatPoint { public float x; public
                          float y;}
                      float Distance(FloatPoint p1, FloatPoint
                      p2) { return Math.Sqrt((p1.x - p2.x) *
                      (p1.x - p2.x) + (p1.y - p2.y) * (p1.y -
                      p2.y)); }
float Distance(float x1, float y1, float x2,
                            float y2) { return Math.Sqrt((x1 - x2) *
Simplify subexpression


                            (x1 - x2) + (y1 - y2) * (y1 - y2));}
                          class FloatPoint { public float x; public
                             float y;} ….
                         float Distance(FloatPoint p1, FloatPoint
                         p2) { return Math.Sqrt(p1.DeltaX(p2) *
                         p1.DeltaX(p2) + Math.Sqrt(p1.Deltay(p2)
                         * p1.DeltaY(p2)); }
class ShapePainter {
      public void Paint(int scale); }
class AreaRenderer {
      public void Render(int multiplier); }
class DrawController {
void DrawObject(object o) {
if (o is ShapePainter)
   ((ShapePainter)(o)).Paint(1); } }
Extract interface
                         interface IShapePainter {
                            void Paint(int scale); }
                         class ShapePainter : IShapePainter {
                              public void Paint(int scale); }

                         class AreaRenderer : IShapePainter{
Use iface




                              public void Paint(int multiplier); }
ren
Use iface




                         void DrawObject(IShapePainter o) {
                         o.Paint(1); }
class ShapePainter {
                          public void Paint(int scale); }
                    class AreaRenderer {
Extract interface




                          public void Render(int multiplier); }
                    class DrawController {
                    void DrawObject(object o) {
                    if (o is ShapePainter)
                       ((ShapePainter)(o)).Paint(1); } }
class TaxCalculator { float rate;
public float GetTax(float income,
   Deductions deductions) { return
   (income - deductions) * rate; } }
class PayRoll { TaxCalculator tax;
Deductions deduct; float income;
float IssueCheck() { if (tax != null)
 return tax.GetTax(income, deduct);

 Else return income; } }
class NullTaxCalculator : TaxCalculator{
              public float GetTax(float income,
                 Deductions deductions) { return 0; } }
              class PayRoll2 { TaxCalculator tax;
Null object




                 Deductions deduct; float income;
              float IssueCheck() { return
                 tax.GetTax(income, deduct); } }
Refactoring
Refactoring
Refactoring
Refactoring

More Related Content

What's hot

Object Oriented Design(s) in R
Object Oriented Design(s) in RObject Oriented Design(s) in R
Object Oriented Design(s) in RRomain Francois
 
Learn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentLearn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentMaty Fedak
 
[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8Alonso Torres
 
matlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequencesmatlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequencesRakesh kumar jha
 
The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.5.4 book - Part 33 of 185The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.5.4 book - Part 33 of 185Mahmoud Samir Fayed
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class PatternsJohn De Goes
 
The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 32 of 189The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 32 of 189Mahmoud Samir Fayed
 
Extractors & Implicit conversions
Extractors & Implicit conversionsExtractors & Implicit conversions
Extractors & Implicit conversionsKnoldus Inc.
 
Intro to functional programming - Confoo
Intro to functional programming - ConfooIntro to functional programming - Confoo
Intro to functional programming - Confoofelixtrepanier
 
The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.2 book - Part 22 of 84The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.2 book - Part 22 of 84Mahmoud Samir Fayed
 
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35Bilal Ahmed
 

What's hot (20)

Comp102 lec 7
Comp102   lec 7Comp102   lec 7
Comp102 lec 7
 
Object Oriented Design(s) in R
Object Oriented Design(s) in RObject Oriented Design(s) in R
Object Oriented Design(s) in R
 
Learn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentLearn basics of Clojure/script and Reagent
Learn basics of Clojure/script and Reagent
 
[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8
 
2java Oop
2java Oop2java Oop
2java Oop
 
Object Oriented Programming using C++ - Part 1
Object Oriented Programming using C++ - Part 1Object Oriented Programming using C++ - Part 1
Object Oriented Programming using C++ - Part 1
 
matlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequencesmatlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequences
 
The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.5.4 book - Part 33 of 185The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.5.4 book - Part 33 of 185
 
Object Oriented Programming using C++ - Part 5
Object Oriented Programming using C++ - Part 5Object Oriented Programming using C++ - Part 5
Object Oriented Programming using C++ - Part 5
 
OOP Core Concept
OOP Core ConceptOOP Core Concept
OOP Core Concept
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class Patterns
 
The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210
 
Object Oriented Programming using C++ - Part 4
Object Oriented Programming using C++ - Part 4Object Oriented Programming using C++ - Part 4
Object Oriented Programming using C++ - Part 4
 
The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 32 of 189The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 32 of 189
 
Extractors & Implicit conversions
Extractors & Implicit conversionsExtractors & Implicit conversions
Extractors & Implicit conversions
 
Intro to functional programming - Confoo
Intro to functional programming - ConfooIntro to functional programming - Confoo
Intro to functional programming - Confoo
 
C# for Java Developers
C# for Java DevelopersC# for Java Developers
C# for Java Developers
 
OOP
OOPOOP
OOP
 
The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.2 book - Part 22 of 84The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.2 book - Part 22 of 84
 
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35
 

Viewers also liked

Woningontwikkeling 2013
Woningontwikkeling 2013Woningontwikkeling 2013
Woningontwikkeling 2013SimonedeMaat
 
Ganadores Fototalentos'13 Fundación Banco Santander
Ganadores Fototalentos'13 Fundación Banco SantanderGanadores Fototalentos'13 Fundación Banco Santander
Ganadores Fototalentos'13 Fundación Banco SantanderFundación Banco Santander
 
Does Dyeing Your Hair Cause Hair Loss?
Does Dyeing Your Hair Cause Hair Loss?Does Dyeing Your Hair Cause Hair Loss?
Does Dyeing Your Hair Cause Hair Loss?johnny89muzon
 
A Digital Project for Your Community
A Digital Project for Your CommunityA Digital Project for Your Community
A Digital Project for Your CommunitySteve Buttry
 
How to make a wikipedia article
How to make a wikipedia articleHow to make a wikipedia article
How to make a wikipedia articleCory_Ward
 
Design and user experience in the travel industry
Design and user experience in the travel industryDesign and user experience in the travel industry
Design and user experience in the travel industryAdam Lee
 

Viewers also liked (11)

Banco magico
Banco magicoBanco magico
Banco magico
 
Woningontwikkeling 2013
Woningontwikkeling 2013Woningontwikkeling 2013
Woningontwikkeling 2013
 
Ganadores Fototalentos'13 Fundación Banco Santander
Ganadores Fototalentos'13 Fundación Banco SantanderGanadores Fototalentos'13 Fundación Banco Santander
Ganadores Fototalentos'13 Fundación Banco Santander
 
Does Dyeing Your Hair Cause Hair Loss?
Does Dyeing Your Hair Cause Hair Loss?Does Dyeing Your Hair Cause Hair Loss?
Does Dyeing Your Hair Cause Hair Loss?
 
Microsoft excel I
Microsoft excel IMicrosoft excel I
Microsoft excel I
 
Escorial3
Escorial3Escorial3
Escorial3
 
A Digital Project for Your Community
A Digital Project for Your CommunityA Digital Project for Your Community
A Digital Project for Your Community
 
pictionary
pictionarypictionary
pictionary
 
How to make a wikipedia article
How to make a wikipedia articleHow to make a wikipedia article
How to make a wikipedia article
 
Design and user experience in the travel industry
Design and user experience in the travel industryDesign and user experience in the travel industry
Design and user experience in the travel industry
 
Ws10 marc bodmer_de
Ws10 marc bodmer_deWs10 marc bodmer_de
Ws10 marc bodmer_de
 

Similar to Refactoring

Implementation of interface9 cm604.30
Implementation of interface9 cm604.30Implementation of interface9 cm604.30
Implementation of interface9 cm604.30myrajendra
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)Ishin Vin
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1Little Tukta Lita
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingabhay singh
 
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Codemotion
 
Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Paulo Morgado
 
TI1220 Lecture 6: First-class Functions
TI1220 Lecture 6: First-class FunctionsTI1220 Lecture 6: First-class Functions
TI1220 Lecture 6: First-class FunctionsEelco Visser
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mark Needham
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performanceintelliyole
 
Design Patterns Reconsidered
Design Patterns ReconsideredDesign Patterns Reconsidered
Design Patterns ReconsideredAlex Miller
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewPaulo Morgado
 
The Noland national flag is a square showing the following pattern. .docx
 The Noland national flag is a square showing the following pattern.  .docx The Noland national flag is a square showing the following pattern.  .docx
The Noland national flag is a square showing the following pattern. .docxKomlin1
 
Les nouveautés de C# 6
Les nouveautés de C# 6Les nouveautés de C# 6
Les nouveautés de C# 6Microsoft
 
Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummiessantiagoaguiar
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional ProgrammingEelco Visser
 

Similar to Refactoring (20)

Implementation of interface9 cm604.30
Implementation of interface9 cm604.30Implementation of interface9 cm604.30
Implementation of interface9 cm604.30
 
SA09 Realtime education
SA09 Realtime educationSA09 Realtime education
SA09 Realtime education
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
 
F#3.0
F#3.0 F#3.0
F#3.0
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7
 
TI1220 Lecture 6: First-class Functions
TI1220 Lecture 6: First-class FunctionsTI1220 Lecture 6: First-class Functions
TI1220 Lecture 6: First-class Functions
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
 
New C# features
New C# featuresNew C# features
New C# features
 
Design Patterns Reconsidered
Design Patterns ReconsideredDesign Patterns Reconsidered
Design Patterns Reconsidered
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
 
The Noland national flag is a square showing the following pattern. .docx
 The Noland national flag is a square showing the following pattern.  .docx The Noland national flag is a square showing the following pattern.  .docx
The Noland national flag is a square showing the following pattern. .docx
 
Mini-curso JavaFX Aula2
Mini-curso JavaFX Aula2Mini-curso JavaFX Aula2
Mini-curso JavaFX Aula2
 
Les nouveautés de C# 6
Les nouveautés de C# 6Les nouveautés de C# 6
Les nouveautés de C# 6
 
Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummies
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
 

Recently uploaded

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
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
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
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
 
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
 
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
 

Recently uploaded (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
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
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
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
 
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
 
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...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 

Refactoring

  • 2. X 2+3x+1==(x+1)(x+2)  Improved code structure  Same executable behavior
  • 3.  Easy write, change  Deferred complexity  Quality  Velocity!
  • 5.  We dig design patterns  We TDD  Incremental
  • 6.  Ensure working version  Create/Ensure tests  Use version control
  • 7.  +:Variable, Method  ++: Class, Class Interaction
  • 8.  Var rename; method rename; method extract  Interface/class extract
  • 9.  Safeand easy  Limited to simple ref’
  • 10.
  • 11.
  • 12.
  • 13.  Distinguish Good Design To the point Readable Simple Predictable/ Modifiable Testable Uncoupled
  • 14.  Where to refactor first? Point Readable Simple Predictable Modify /uncoupled Dup code Renaming Switch Refused Parallel Large class Long method bequest hierarchy Lazy class Large class Feature Speculative Envy generality Intimacy
  • 16.  Takean example of smell and a change
  • 18.  Demo  Identify the qualities
  • 20.  Minor: As you go  Major: At mini- feature/class completion  Not as a separate milestone
  • 22.  Refactoring projects  Code and fix  Performance  Procastination
  • 23.  Your ref’experience  Favorite ref’ moves
  • 24.  Hopefully, answers
  • 27.  Before and after refactoring  Refactoring tools menus
  • 28. int ProcessX(int x) { return x+1; } Ren method int IncrementPosition(int x) { return x+1; } int IncrementPosition(int Ren var oldPos) { return oldPos+1; }
  • 29.
  • 30. float Distance(float x1, float y1, float x2, float y2) { return Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));} Param list to class class FloatPoint { public float x; public float y;} float Distance(FloatPoint p1, FloatPoint p2) { return Math.Sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)); }
  • 31. float Distance(float x1, float y1, float x2, float y2) { return Math.Sqrt((x1 - x2) * Simplify subexpression (x1 - x2) + (y1 - y2) * (y1 - y2));} class FloatPoint { public float x; public float y;} …. float Distance(FloatPoint p1, FloatPoint p2) { return Math.Sqrt(p1.DeltaX(p2) * p1.DeltaX(p2) + Math.Sqrt(p1.Deltay(p2) * p1.DeltaY(p2)); }
  • 32.
  • 33. class ShapePainter { public void Paint(int scale); } class AreaRenderer { public void Render(int multiplier); } class DrawController { void DrawObject(object o) { if (o is ShapePainter) ((ShapePainter)(o)).Paint(1); } }
  • 34. Extract interface interface IShapePainter { void Paint(int scale); } class ShapePainter : IShapePainter { public void Paint(int scale); } class AreaRenderer : IShapePainter{ Use iface public void Paint(int multiplier); } ren Use iface void DrawObject(IShapePainter o) { o.Paint(1); }
  • 35. class ShapePainter { public void Paint(int scale); } class AreaRenderer { Extract interface public void Render(int multiplier); } class DrawController { void DrawObject(object o) { if (o is ShapePainter) ((ShapePainter)(o)).Paint(1); } }
  • 36.
  • 37. class TaxCalculator { float rate; public float GetTax(float income, Deductions deductions) { return (income - deductions) * rate; } } class PayRoll { TaxCalculator tax; Deductions deduct; float income; float IssueCheck() { if (tax != null)  return tax.GetTax(income, deduct);  Else return income; } }
  • 38. class NullTaxCalculator : TaxCalculator{ public float GetTax(float income, Deductions deductions) { return 0; } } class PayRoll2 { TaxCalculator tax; Null object Deductions deduct; float income; float IssueCheck() { return tax.GetTax(income, deduct); } }