SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
Refactoring 2 TheMax
 Alfredo Morresi: www.rainbowbreeze.it
  Diego Guidi: lacorrente.blogspot.com
          staff@dotnetmarche.org
Shit happens

Anything that can go wrong will go
              wrong.
            (Arthur Bloch)
Underengineering

AKA "fast, slow, slower.... never :("
 quickly deliver 1.0 release that works well for our
  customers but with junky code
 working on 2.0 release, junky code slows you down,
  and new features are harder to implement
 as junky code multiplies, people lose faith into the
  system and the programmers
 planning next release, you realize you can't win, and
  start thinking about a total rewrite
Overengineering

AKA "the 'HelloWorld' pattern"
 code more sophisticated that it possible future
  requirements
 code hard to understand for new ones

 time wasted understanding and maintaining complex
  code so you need to write documentation
Code smells

   copy/paste (duplicate) code
   large method/class
   method-like properties
   contrived complexity (patterns everywhere!)
   inappropriate intimacy
   unused code
   dangerous if (if - else if - else if - else...)
Cunningham's metaphor

The technical language doesn't communicate
effectively with the vast majority of management.
Instead, Ward Cunningham's financial metaphor of
design debt works infinitely better.
Design debt occurs when you don't consistently do
three things.
1. Remove duplication.
2. Simplify your code.
3. Clarify you code's intent.
Cunningham's metaphor

 Few systems remain completely free of design debt.
Wired as we are, humans just don't write perfect code
the first time around. We naturally accumulate design
             debt. So the question becomes:


   "When do you pay it down?"
And so, refactoring!

   Refactoring is the process of changing a software
system in such a way that it does not alter the external
     behavior of the code yet improves its internal
                        structure.

A refactoring is a "behavior-preserving transformation"
 or, as Martin Fowler defines it, "a change made to the
    internal structure of software to make it easier to
understand and cheaper to modify without changing its
                   observable behavior"
Why refactoring?

   Code i wrote yesterday is worse that code i'm writing
    today
   Make it easier to add new code
   Improve the design of existing code
   Gain a better understanding of code
   Make coding less annoying
   Readability / Testability / Estensibility
   bugs correction
   ...
When refactoring?

   Keeping code clean is a lot like keeping a room
    clean. Once your room becomes a mess, it becomes
    harder to clean. The worse the mess becomes, the
    less you want to clean it.
   It's best to refactor continuously, rather than in
    phases. When you see code that needs
    improvement, improve it.
   On the other hand, if your manager needs you to
    finish a feature before a demo that just got
    scheduled for tomorrow, finish the feature and
    refactor later!
When NOT refactoring?

   If it's working, don't change
   if you have a poorly factored program
   if your code isn't tested, that does what the
    customer wants and has no serious bugs, leave it
    alone!
   performance matters...
How refactoring

Refactoring recipes
 extract superclass/interface

 rename method/property/variable

 replace conditional with polymorphism

 replace constructor with factory method

 inline method

 even more: http://www.refactoring.com/catalog
How refactoring

 Only refactor when refactoring -- do not add feature
                 during refactoring.

Refactoring, or improving the design of existing code,
requires that you know what code needs improvement.
How refactoring

Each transformation (called a "Refactoring") does little,
  but a sequence of transformations can produce a
              significant restructuring.

The system is also kept fully working after each small
 refactoring, reducing the chances that a system can
get seriously broken during the restructuring process.
How refactoring



If you want to refactor, the essential
   precondition is having solid test
             (Martin Fowler)
Test-Driven Development



   Test-driven development (TDD) and continuous
 refactoring enable the efficient evolution of working
    code by turning programming into a dialogue.
Test-Driven Development

Ask: You ask a question of a system by writing a test.
Respond: You respond to the question by writing
code to pass the test.
Refine: You refine your response by consolidating
ideas, weeding out inessentials, and clarifying
ambiguities.
Repeat: You keep the dialogue going by asking the
next question.
Refactoring and pattern

 There is a natural relation between
 patterns and refactorings. Patterns
     are where you want to be;
 refactorings are ways to get there
       from somewhere else.
             (Fowler Martin)
Refactoring and pattern

   Each pattern is a three-part rule, which expresses a
    relation between a certain context, a problem, and a
    solution.
   There are many ways to implement a pattern. If you
    don't know patterns, you're less likely to evolve great
    designs. Patterns capture wisdom. Reusing that
    wisdom is extremely useful, also when refactoring.
Readings

   Refactoring: Improving the Design of Existing Code
    (Martin Fowler)

   Refactoring to patterns
    (Joshua Kerievsky)

   Design Patterns: Elements of Reusable Object-
    Oriented Software
    (Gang of Four)

   The Pragmatic Programmer
    (Andrew Hunt and David Thomas)
The sage final sentence


          Any fool can write code
            that a computer can
             understand. Good
          programmers write code
              that humans can
                understand.
                   (M. F.)
Questions?

Contenu connexe

Tendances

Test driven developement
Test driven developementTest driven developement
Test driven developementBhavik Panchal
 
Tdd 왜 배우기 어려운가
Tdd 왜 배우기 어려운가Tdd 왜 배우기 어려운가
Tdd 왜 배우기 어려운가Jaehoon Oh
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Søren Lund
 
Best Practices of Software Development
Best Practices of Software DevelopmentBest Practices of Software Development
Best Practices of Software DevelopmentFolio3 Software
 
Six Steps to Conversation Driven Development
Six Steps to Conversation Driven DevelopmentSix Steps to Conversation Driven Development
Six Steps to Conversation Driven DevelopmentRasa Technologies
 
Feedback on Part 1 of the Software Engineering Large Practical
Feedback on Part 1 of the Software Engineering Large PracticalFeedback on Part 1 of the Software Engineering Large Practical
Feedback on Part 1 of the Software Engineering Large PracticalStephen Gilmore
 
Mark asoi ppt
Mark asoi pptMark asoi ppt
Mark asoi pptmark-asoi
 
Feedback on Part 1 of the CSLP
Feedback on Part 1 of the CSLPFeedback on Part 1 of the CSLP
Feedback on Part 1 of the CSLPStephen Gilmore
 
TDD for the masses
TDD for the massesTDD for the masses
TDD for the massesJorge Ortiz
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship ChecklistRyan Polk
 
hints for computer system design by Butler Lampson
hints for computer system design by Butler Lampsonhints for computer system design by Butler Lampson
hints for computer system design by Butler Lampsonmustafa sarac
 
A Software Problem (and a maybe-solution)
A Software Problem (and a maybe-solution)A Software Problem (and a maybe-solution)
A Software Problem (and a maybe-solution)YangJerng Hwa
 
Why pay two developers to do the work of one?
Why pay two developers to do the work of one?Why pay two developers to do the work of one?
Why pay two developers to do the work of one?📈 Paige Watson
 

Tendances (16)

Test driven developement
Test driven developementTest driven developement
Test driven developement
 
Tdd 왜 배우기 어려운가
Tdd 왜 배우기 어려운가Tdd 왜 배우기 어려운가
Tdd 왜 배우기 어려운가
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016
 
Best Practices of Software Development
Best Practices of Software DevelopmentBest Practices of Software Development
Best Practices of Software Development
 
Learning Curve
Learning CurveLearning Curve
Learning Curve
 
Six Steps to Conversation Driven Development
Six Steps to Conversation Driven DevelopmentSix Steps to Conversation Driven Development
Six Steps to Conversation Driven Development
 
Feedback on Part 1 of the Software Engineering Large Practical
Feedback on Part 1 of the Software Engineering Large PracticalFeedback on Part 1 of the Software Engineering Large Practical
Feedback on Part 1 of the Software Engineering Large Practical
 
What's in a Name?
What's in a Name?What's in a Name?
What's in a Name?
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Mark asoi ppt
Mark asoi pptMark asoi ppt
Mark asoi ppt
 
Feedback on Part 1 of the CSLP
Feedback on Part 1 of the CSLPFeedback on Part 1 of the CSLP
Feedback on Part 1 of the CSLP
 
TDD for the masses
TDD for the massesTDD for the masses
TDD for the masses
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship Checklist
 
hints for computer system design by Butler Lampson
hints for computer system design by Butler Lampsonhints for computer system design by Butler Lampson
hints for computer system design by Butler Lampson
 
A Software Problem (and a maybe-solution)
A Software Problem (and a maybe-solution)A Software Problem (and a maybe-solution)
A Software Problem (and a maybe-solution)
 
Why pay two developers to do the work of one?
Why pay two developers to do the work of one?Why pay two developers to do the work of one?
Why pay two developers to do the work of one?
 

En vedette

Strategie di Enterprise Mobile Security, per una gestione sicura dei disposit...
Strategie di Enterprise Mobile Security, per una gestione sicura dei disposit...Strategie di Enterprise Mobile Security, per una gestione sicura dei disposit...
Strategie di Enterprise Mobile Security, per una gestione sicura dei disposit...festival ICT 2016
 
Mobile security & privacy - Paranoia in movimento
Mobile security & privacy - Paranoia in movimentoMobile security & privacy - Paranoia in movimento
Mobile security & privacy - Paranoia in movimentoAlfredo Morresi
 
MDM is not Enough - Parmelee
MDM is not Enough - Parmelee MDM is not Enough - Parmelee
MDM is not Enough - Parmelee Prolifics
 
Mobile Data Security: Sicurezza IT per aziende in movimento
Mobile Data Security: Sicurezza IT per aziende in movimentoMobile Data Security: Sicurezza IT per aziende in movimento
Mobile Data Security: Sicurezza IT per aziende in movimentoBabel
 
Advanced Android Development
Advanced Android DevelopmentAdvanced Android Development
Advanced Android DevelopmentAlfredo Morresi
 
Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Alfredo Morresi
 
Android Survival Guide - Two years of software development
Android Survival Guide - Two years of software developmentAndroid Survival Guide - Two years of software development
Android Survival Guide - Two years of software developmentAlfredo Morresi
 
L’innovazione a difesa della tradizione: il caso dell’Archivio Storico della ...
L’innovazione a difesa della tradizione: il caso dell’Archivio Storico della ...L’innovazione a difesa della tradizione: il caso dell’Archivio Storico della ...
L’innovazione a difesa della tradizione: il caso dell’Archivio Storico della ...Babel
 
Sophos Complete Security: arte e scienza della sicurezza
Sophos Complete Security: arte e scienza della sicurezzaSophos Complete Security: arte e scienza della sicurezza
Sophos Complete Security: arte e scienza della sicurezzaBabel
 

En vedette (9)

Strategie di Enterprise Mobile Security, per una gestione sicura dei disposit...
Strategie di Enterprise Mobile Security, per una gestione sicura dei disposit...Strategie di Enterprise Mobile Security, per una gestione sicura dei disposit...
Strategie di Enterprise Mobile Security, per una gestione sicura dei disposit...
 
Mobile security & privacy - Paranoia in movimento
Mobile security & privacy - Paranoia in movimentoMobile security & privacy - Paranoia in movimento
Mobile security & privacy - Paranoia in movimento
 
MDM is not Enough - Parmelee
MDM is not Enough - Parmelee MDM is not Enough - Parmelee
MDM is not Enough - Parmelee
 
Mobile Data Security: Sicurezza IT per aziende in movimento
Mobile Data Security: Sicurezza IT per aziende in movimentoMobile Data Security: Sicurezza IT per aziende in movimento
Mobile Data Security: Sicurezza IT per aziende in movimento
 
Advanced Android Development
Advanced Android DevelopmentAdvanced Android Development
Advanced Android Development
 
Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)
 
Android Survival Guide - Two years of software development
Android Survival Guide - Two years of software developmentAndroid Survival Guide - Two years of software development
Android Survival Guide - Two years of software development
 
L’innovazione a difesa della tradizione: il caso dell’Archivio Storico della ...
L’innovazione a difesa della tradizione: il caso dell’Archivio Storico della ...L’innovazione a difesa della tradizione: il caso dell’Archivio Storico della ...
L’innovazione a difesa della tradizione: il caso dell’Archivio Storico della ...
 
Sophos Complete Security: arte e scienza della sicurezza
Sophos Complete Security: arte e scienza della sicurezzaSophos Complete Security: arte e scienza della sicurezza
Sophos Complete Security: arte e scienza della sicurezza
 

Similaire à Refactoring 2 The Max

Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Editionjexp
 
2018 01-29 - brewbox - refactoring. sempre, senza pietà
2018 01-29 - brewbox - refactoring. sempre, senza pietà2018 01-29 - brewbox - refactoring. sempre, senza pietà
2018 01-29 - brewbox - refactoring. sempre, senza pietàRoberto Albertini
 
Refactoring 2TheMax (con ReSharper)
Refactoring 2TheMax (con ReSharper)Refactoring 2TheMax (con ReSharper)
Refactoring 2TheMax (con ReSharper)DotNetMarche
 
Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in RefactoringChamnap Chhorn
 
Agile Methodologies And Extreme Programming
Agile Methodologies And Extreme ProgrammingAgile Methodologies And Extreme Programming
Agile Methodologies And Extreme ProgrammingUtkarsh Khare
 
Agile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovAgile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovSvetlin Nakov
 
Refactoring, A First Example
Refactoring, A First ExampleRefactoring, A First Example
Refactoring, A First ExampleVorleak Chy
 
10 Ways To Improve Your Code( Neal Ford)
10  Ways To  Improve  Your  Code( Neal  Ford)10  Ways To  Improve  Your  Code( Neal  Ford)
10 Ways To Improve Your Code( Neal Ford)guestebde
 
WordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressWordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressmtoppa
 
Agile Values, Principles and Practices
Agile Values, Principles and PracticesAgile Values, Principles and Practices
Agile Values, Principles and Practicesjackcrews
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016Søren Lund
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design PatternJaswant Singh
 
Why Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software EngineeringWhy Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software EngineeringProtelo, Inc.
 
Techfest design patterns
Techfest design patternsTechfest design patterns
Techfest design patternsRookieOne
 

Similaire à Refactoring 2 The Max (20)

Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Edition
 
2018 01-29 - brewbox - refactoring. sempre, senza pietà
2018 01-29 - brewbox - refactoring. sempre, senza pietà2018 01-29 - brewbox - refactoring. sempre, senza pietà
2018 01-29 - brewbox - refactoring. sempre, senza pietà
 
Refactoring 2TheMax (con ReSharper)
Refactoring 2TheMax (con ReSharper)Refactoring 2TheMax (con ReSharper)
Refactoring 2TheMax (con ReSharper)
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
 
Quick Intro to Clean Coding
Quick Intro to Clean CodingQuick Intro to Clean Coding
Quick Intro to Clean Coding
 
Refactoring
RefactoringRefactoring
Refactoring
 
Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in Refactoring
 
Agile Methodologies And Extreme Programming
Agile Methodologies And Extreme ProgrammingAgile Methodologies And Extreme Programming
Agile Methodologies And Extreme Programming
 
Agile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovAgile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin Nakov
 
Refactoring, A First Example
Refactoring, A First ExampleRefactoring, A First Example
Refactoring, A First Example
 
10 Ways To Improve Your Code( Neal Ford)
10  Ways To  Improve  Your  Code( Neal  Ford)10  Ways To  Improve  Your  Code( Neal  Ford)
10 Ways To Improve Your Code( Neal Ford)
 
WordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressWordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPress
 
10 Ways To Improve Your Code
10 Ways To Improve Your Code10 Ways To Improve Your Code
10 Ways To Improve Your Code
 
Agile Values, Principles and Practices
Agile Values, Principles and PracticesAgile Values, Principles and Practices
Agile Values, Principles and Practices
 
Best pratice
Best praticeBest pratice
Best pratice
 
Code Quality
Code QualityCode Quality
Code Quality
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
 
Why Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software EngineeringWhy Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software Engineering
 
Techfest design patterns
Techfest design patternsTechfest design patterns
Techfest design patterns
 

Plus de Alfredo Morresi

Testing in Android: automatici, di integrazione, TDD e scenari avanzati
Testing in Android: automatici, di integrazione, TDD e scenari avanzatiTesting in Android: automatici, di integrazione, TDD e scenari avanzati
Testing in Android: automatici, di integrazione, TDD e scenari avanzatiAlfredo Morresi
 
Mobile platforms development overview
Mobile platforms development overviewMobile platforms development overview
Mobile platforms development overviewAlfredo Morresi
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications developmentAlfredo Morresi
 
Funambol Code Sniper - Avatargrabber
Funambol Code Sniper - AvatargrabberFunambol Code Sniper - Avatargrabber
Funambol Code Sniper - AvatargrabberAlfredo Morresi
 
Tesi cartoni animati e modelli culturali
Tesi cartoni animati e modelli culturaliTesi cartoni animati e modelli culturali
Tesi cartoni animati e modelli culturaliAlfredo Morresi
 
(in)Sicurezze delle reti wireless 802.11b
(in)Sicurezze delle reti wireless 802.11b(in)Sicurezze delle reti wireless 802.11b
(in)Sicurezze delle reti wireless 802.11bAlfredo Morresi
 
BlueSecurity: quando il dente fa male!
BlueSecurity: quando il dente fa male!BlueSecurity: quando il dente fa male!
BlueSecurity: quando il dente fa male!Alfredo Morresi
 
2(.0) passi nel mondo mobile - Alfredo Morresi
2(.0) passi nel mondo mobile - Alfredo Morresi2(.0) passi nel mondo mobile - Alfredo Morresi
2(.0) passi nel mondo mobile - Alfredo MorresiAlfredo Morresi
 
QR code - Alfredo Morresi
QR code - Alfredo MorresiQR code - Alfredo Morresi
QR code - Alfredo MorresiAlfredo Morresi
 

Plus de Alfredo Morresi (9)

Testing in Android: automatici, di integrazione, TDD e scenari avanzati
Testing in Android: automatici, di integrazione, TDD e scenari avanzatiTesting in Android: automatici, di integrazione, TDD e scenari avanzati
Testing in Android: automatici, di integrazione, TDD e scenari avanzati
 
Mobile platforms development overview
Mobile platforms development overviewMobile platforms development overview
Mobile platforms development overview
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications development
 
Funambol Code Sniper - Avatargrabber
Funambol Code Sniper - AvatargrabberFunambol Code Sniper - Avatargrabber
Funambol Code Sniper - Avatargrabber
 
Tesi cartoni animati e modelli culturali
Tesi cartoni animati e modelli culturaliTesi cartoni animati e modelli culturali
Tesi cartoni animati e modelli culturali
 
(in)Sicurezze delle reti wireless 802.11b
(in)Sicurezze delle reti wireless 802.11b(in)Sicurezze delle reti wireless 802.11b
(in)Sicurezze delle reti wireless 802.11b
 
BlueSecurity: quando il dente fa male!
BlueSecurity: quando il dente fa male!BlueSecurity: quando il dente fa male!
BlueSecurity: quando il dente fa male!
 
2(.0) passi nel mondo mobile - Alfredo Morresi
2(.0) passi nel mondo mobile - Alfredo Morresi2(.0) passi nel mondo mobile - Alfredo Morresi
2(.0) passi nel mondo mobile - Alfredo Morresi
 
QR code - Alfredo Morresi
QR code - Alfredo MorresiQR code - Alfredo Morresi
QR code - Alfredo Morresi
 

Dernier

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 

Refactoring 2 The Max

  • 1. Refactoring 2 TheMax Alfredo Morresi: www.rainbowbreeze.it Diego Guidi: lacorrente.blogspot.com staff@dotnetmarche.org
  • 2. Shit happens Anything that can go wrong will go wrong. (Arthur Bloch)
  • 3. Underengineering AKA "fast, slow, slower.... never :("  quickly deliver 1.0 release that works well for our customers but with junky code  working on 2.0 release, junky code slows you down, and new features are harder to implement  as junky code multiplies, people lose faith into the system and the programmers  planning next release, you realize you can't win, and start thinking about a total rewrite
  • 4. Overengineering AKA "the 'HelloWorld' pattern"  code more sophisticated that it possible future requirements  code hard to understand for new ones  time wasted understanding and maintaining complex code so you need to write documentation
  • 5. Code smells  copy/paste (duplicate) code  large method/class  method-like properties  contrived complexity (patterns everywhere!)  inappropriate intimacy  unused code  dangerous if (if - else if - else if - else...)
  • 6. Cunningham's metaphor The technical language doesn't communicate effectively with the vast majority of management. Instead, Ward Cunningham's financial metaphor of design debt works infinitely better. Design debt occurs when you don't consistently do three things. 1. Remove duplication. 2. Simplify your code. 3. Clarify you code's intent.
  • 7. Cunningham's metaphor Few systems remain completely free of design debt. Wired as we are, humans just don't write perfect code the first time around. We naturally accumulate design debt. So the question becomes: "When do you pay it down?"
  • 8. And so, refactoring! Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure. A refactoring is a "behavior-preserving transformation" or, as Martin Fowler defines it, "a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior"
  • 9. Why refactoring?  Code i wrote yesterday is worse that code i'm writing today  Make it easier to add new code  Improve the design of existing code  Gain a better understanding of code  Make coding less annoying  Readability / Testability / Estensibility  bugs correction  ...
  • 10. When refactoring?  Keeping code clean is a lot like keeping a room clean. Once your room becomes a mess, it becomes harder to clean. The worse the mess becomes, the less you want to clean it.  It's best to refactor continuously, rather than in phases. When you see code that needs improvement, improve it.  On the other hand, if your manager needs you to finish a feature before a demo that just got scheduled for tomorrow, finish the feature and refactor later!
  • 11. When NOT refactoring?  If it's working, don't change  if you have a poorly factored program  if your code isn't tested, that does what the customer wants and has no serious bugs, leave it alone!  performance matters...
  • 12. How refactoring Refactoring recipes  extract superclass/interface  rename method/property/variable  replace conditional with polymorphism  replace constructor with factory method  inline method  even more: http://www.refactoring.com/catalog
  • 13. How refactoring Only refactor when refactoring -- do not add feature during refactoring. Refactoring, or improving the design of existing code, requires that you know what code needs improvement.
  • 14. How refactoring Each transformation (called a "Refactoring") does little, but a sequence of transformations can produce a significant restructuring. The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring process.
  • 15. How refactoring If you want to refactor, the essential precondition is having solid test (Martin Fowler)
  • 16. Test-Driven Development Test-driven development (TDD) and continuous refactoring enable the efficient evolution of working code by turning programming into a dialogue.
  • 17. Test-Driven Development Ask: You ask a question of a system by writing a test. Respond: You respond to the question by writing code to pass the test. Refine: You refine your response by consolidating ideas, weeding out inessentials, and clarifying ambiguities. Repeat: You keep the dialogue going by asking the next question.
  • 18. Refactoring and pattern There is a natural relation between patterns and refactorings. Patterns are where you want to be; refactorings are ways to get there from somewhere else. (Fowler Martin)
  • 19. Refactoring and pattern  Each pattern is a three-part rule, which expresses a relation between a certain context, a problem, and a solution.  There are many ways to implement a pattern. If you don't know patterns, you're less likely to evolve great designs. Patterns capture wisdom. Reusing that wisdom is extremely useful, also when refactoring.
  • 20. Readings  Refactoring: Improving the Design of Existing Code (Martin Fowler)  Refactoring to patterns (Joshua Kerievsky)  Design Patterns: Elements of Reusable Object- Oriented Software (Gang of Four)  The Pragmatic Programmer (Andrew Hunt and David Thomas)
  • 21. The sage final sentence Any fool can write code that a computer can understand. Good programmers write code that humans can understand. (M. F.)