SlideShare uma empresa Scribd logo
1 de 17
Refactoring
Group 1
 Bad Smells in Code

 Building Tests

 Composing Methods


   Confidential          2
Bad Smells in Code


Who          What            When


Where        Why             How

              Confidential          3
Confidential   4
…..
<app key=“ContactEmailAddress” value=“jdoe@initrode.com” />
…..

                                             app.config (revision 1)




…..
<app key=“sContactEmailAddress” value=“jdoe@initrode.com” />
…..

                                             app.config (revision 2)




                              Confidential                             5
// I decided not to use built-in feature to
                                                                     convert string to boolean

                                                                     if ( is_string($switch) ) {
                                                                            switch ($switch) {
      Public Function Save() As Boolean                                        case 'false' :
        Try                                                                    case 'down' :
           SaveMeeting()                                                       case 'off' :
        Catch ex As Exception                                                  case 'not' :
           Throw ex                                                            case '0' :
        End Try                                                                case '' :
      End Function                                                                $switch = false;
                                                                                  break;

                                                                               default :
                                                                                 $switch = true;
                                                                                 break;
                                                                           }
                                                                     }
<a href="/the/path/to/the/url"
onclick="window.open(this.getAttribute('href'),'_blank');return false;">
 link text
</a>


                                                          Confidential                                             6
// Translates Roman Numbers to
                                                           Decimal Numbers
Function GetNewGuid()                                      public string rom2num(string r)
  Dim cnGuid, rsGuid                                       {
                                                              if (r == "I") return "1";
  Set cnGuid = CreateObject("ADODB.Connection")               if (r == "II") return "2";
  Set rsGuid = CreateObject("ADODB.Recordset")                if (r == "III") return "3";
                                                              if (r == "IV") return "4";
  cnGuid.Open = _                                             if (r == "V") return "5";
    "Provider=SQLOLEDB.1;" +                                  if (r == "VI") return "6";
    "Data Source=<production server>; " +                     if (r == "VII") return "7";
    "Initial Catalog=<production DB> " +                      if (r == "VIII") return "8";
    "user id = '********';" +                                 if (r == "IX") return "9";
    "password='*********'""                                   //
                                                              // Snipped LOTS of "code" here
  rsGuid.Open "SELECT newid() as Guid", cnGuid                //
                                                              if (r == "MMVIII") return "2008";
  If Not rsGuid.EOF Then                                      if (r == "MMIX") return "2009";
     GetNewGuid = rsGuid("Guid").Value                        if (r == "MMX") return "2010";
  End If                                                      if (r == "MMXI") return "2011";
End Function                                                  return "E";
                                                           }




                                            Confidential                                          7
function checkdata() {
  dataok = true;
  t1 = document.forms.signup.firstName.value;
  t2 = document.forms.signup.lastName.value;
  t9 = document.forms.signup.locale.options.selectedIndex;
  t10 = document.forms.signup.currency.options.selectedIndex;
  t11 = document.forms.signup.timezone.options.selectedIndex;
  t12 = document.forms.signup.packetType.options.selectedIndex;
  t13 = document.forms.signup.captcha_code.value;
  if (t1 == '' || t2 == '„ ) {
      alert("Please fill-up all the fields");
      dataok = false; return(dataok);}
  if (t4 != t5) {
      alert("Please enter the password again");
      dataok = false; return(dataok);}
  if (t9 == 0) {
      alert("Please select a locale");
      dataok = false; return(dataok);}
  if (t10 == 0) {
      alert("Please select a currency");
      dataok = false; return(dataok);}
  return(dataok);
}




                                Confidential                      8
// Self-document code

private bool TrueBecauseThisEventDoesNotRegistrictBasedUponActivityType()
{
  return true;
}

private bool FalseBecauseNoActivityTypesAreAvailableForUsersWhoAreNotLoggedIn()
{
  return false;
}


private bool NoActivityTypesAreAttachedToThisEvent(IEnumerable<ActivityType>
activityTypes)
{
  return activityTypes.Any() == false;
}




                                    Confidential                                  9
# Find the last 200 transactions
    logging.debug( "Finding the last 600 transactions" )
    ConnMysql.query("select Id from Transactions order by ts desc limit 0,10000 ")




private void EditTDemensions(bool blnYes)
{
   //bln is the introvert of blnYes
   bool bln = (blnYes ? false : true);

    //Display or Hide buttons
    btnDemensionsEdit.Visible = bln;
    btnDemensionsSave.Visible = blnYes;
    btnDemensionsCancel.Visible = blnYes;
}




                                     Confidential                                    10
 Bad Smells in Code

   Building Tests

 Composing Methods


   Confidential        11
Self-testing Code




      Confidential   12
Without Self-testing Code

Developer jobs




 Fix bugs   Others

                     Confidential   13
 Bad Smells in Code


 Building Tests

   Composing Methods


   Confidential        14
Catalog of Refactorings


Composing Methods Simplifying Conditional
Moving Features    Expressions
 Between Objects   Making Method Calls
Organizing Data    Simpler
                   Dealing with
                    Generalization


                   Confidential           15
Inline Method
  Extract Method
                           Substitute Algorithm
Replace Temp with Query           Inline Temp
         Introduce Explaining Variable

  Replace Method with Method Object
    Split Temporary Variable
Remove Assignments to Parameters
                   Confidential             16
THANK YOU

Mais conteúdo relacionado

Mais procurados

Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bitsChris Saylor
 
Wait queue
Wait queueWait queue
Wait queueRoy Lee
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6Richard Jones
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayNatasha Murashev
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testingVisual Engineering
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScriptSimon Willison
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...go_oh
 
Testing JavaScript/CoffeeScript with Mocha and Chai
Testing JavaScript/CoffeeScript with Mocha and ChaiTesting JavaScript/CoffeeScript with Mocha and Chai
Testing JavaScript/CoffeeScript with Mocha and ChaiMark
 
Hardened JavaScript
Hardened JavaScriptHardened JavaScript
Hardened JavaScriptKrisKowal2
 
LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기Wanbok Choi
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8XSolve
 
PHP Traits
PHP TraitsPHP Traits
PHP Traitsmattbuzz
 
IP project for class 12 cbse
IP project for class 12 cbseIP project for class 12 cbse
IP project for class 12 cbsesiddharthjha34
 
RxSwift 활용하기 - Let'Swift 2017
RxSwift 활용하기 - Let'Swift 2017RxSwift 활용하기 - Let'Swift 2017
RxSwift 활용하기 - Let'Swift 2017Wanbok Choi
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Aaron Gustafson
 
شرح مقرر البرمجة 2 لغة جافا - الوحدة الرابعة
شرح مقرر البرمجة 2   لغة جافا - الوحدة الرابعةشرح مقرر البرمجة 2   لغة جافا - الوحدة الرابعة
شرح مقرر البرمجة 2 لغة جافا - الوحدة الرابعةجامعة القدس المفتوحة
 
Swift internals
Swift internalsSwift internals
Swift internalsJung Kim
 

Mais procurados (20)

Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bits
 
Wait queue
Wait queueWait queue
Wait queue
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6
 
Specs2
Specs2Specs2
Specs2
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional Way
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testing
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...
 
Testing JavaScript/CoffeeScript with Mocha and Chai
Testing JavaScript/CoffeeScript with Mocha and ChaiTesting JavaScript/CoffeeScript with Mocha and Chai
Testing JavaScript/CoffeeScript with Mocha and Chai
 
Hardened JavaScript
Hardened JavaScriptHardened JavaScript
Hardened JavaScript
 
LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8
 
PHP Traits
PHP TraitsPHP Traits
PHP Traits
 
IP project for class 12 cbse
IP project for class 12 cbseIP project for class 12 cbse
IP project for class 12 cbse
 
RxSwift 활용하기 - Let'Swift 2017
RxSwift 활용하기 - Let'Swift 2017RxSwift 활용하기 - Let'Swift 2017
RxSwift 활용하기 - Let'Swift 2017
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]
 
شرح مقرر البرمجة 2 لغة جافا - الوحدة الرابعة
شرح مقرر البرمجة 2   لغة جافا - الوحدة الرابعةشرح مقرر البرمجة 2   لغة جافا - الوحدة الرابعة
شرح مقرر البرمجة 2 لغة جافا - الوحدة الرابعة
 
Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++
 
Swift internals
Swift internalsSwift internals
Swift internals
 

Destaque

FCP Webinar 7 - 13th April 2011
FCP Webinar 7 - 13th April 2011FCP Webinar 7 - 13th April 2011
FCP Webinar 7 - 13th April 2011Dent
 
Soal quizz lp3i manyar-corel draw
Soal quizz lp3i manyar-corel drawSoal quizz lp3i manyar-corel draw
Soal quizz lp3i manyar-corel drawprihardini
 
Firefox OSの何が嬉しいか
Firefox OSの何が嬉しいかFirefox OSの何が嬉しいか
Firefox OSの何が嬉しいかTakao Sumitomo
 
Building Single-page Web Applications with AngularJS @ TechCamp Sai Gon 2014
Building Single-page Web Applications with AngularJS @ TechCamp Sai Gon 2014Building Single-page Web Applications with AngularJS @ TechCamp Sai Gon 2014
Building Single-page Web Applications with AngularJS @ TechCamp Sai Gon 2014Duy Lâm
 
Overview of character encoding
Overview of character encodingOverview of character encoding
Overview of character encodingDuy Lâm
 
KMS TechCon 2014 - Interesting in JavaScript
KMS TechCon 2014 - Interesting in JavaScriptKMS TechCon 2014 - Interesting in JavaScript
KMS TechCon 2014 - Interesting in JavaScriptDuy Lâm
 
Amazon Web Services
Amazon Web ServicesAmazon Web Services
Amazon Web ServicesDuy Lâm
 
Building creative expression
Building creative expressionBuilding creative expression
Building creative expressionrichardofaustin
 
Caching and IPC with Redis
Caching and IPC with RedisCaching and IPC with Redis
Caching and IPC with RedisKMS Technology
 
Advantages of Cassandra's masterless architecture
Advantages of Cassandra's masterless architectureAdvantages of Cassandra's masterless architecture
Advantages of Cassandra's masterless architectureDuy Lâm
 
Visual Resume
Visual ResumeVisual Resume
Visual ResumeCriser01
 

Destaque (14)

FCP Webinar 7 - 13th April 2011
FCP Webinar 7 - 13th April 2011FCP Webinar 7 - 13th April 2011
FCP Webinar 7 - 13th April 2011
 
Soal quizz lp3i manyar-corel draw
Soal quizz lp3i manyar-corel drawSoal quizz lp3i manyar-corel draw
Soal quizz lp3i manyar-corel draw
 
Firefox OSの何が嬉しいか
Firefox OSの何が嬉しいかFirefox OSの何が嬉しいか
Firefox OSの何が嬉しいか
 
Copyright rev0.5
Copyright rev0.5Copyright rev0.5
Copyright rev0.5
 
Copyright rev0.3
Copyright rev0.3Copyright rev0.3
Copyright rev0.3
 
Mocha
Mocha Mocha
Mocha
 
Building Single-page Web Applications with AngularJS @ TechCamp Sai Gon 2014
Building Single-page Web Applications with AngularJS @ TechCamp Sai Gon 2014Building Single-page Web Applications with AngularJS @ TechCamp Sai Gon 2014
Building Single-page Web Applications with AngularJS @ TechCamp Sai Gon 2014
 
Overview of character encoding
Overview of character encodingOverview of character encoding
Overview of character encoding
 
KMS TechCon 2014 - Interesting in JavaScript
KMS TechCon 2014 - Interesting in JavaScriptKMS TechCon 2014 - Interesting in JavaScript
KMS TechCon 2014 - Interesting in JavaScript
 
Amazon Web Services
Amazon Web ServicesAmazon Web Services
Amazon Web Services
 
Building creative expression
Building creative expressionBuilding creative expression
Building creative expression
 
Caching and IPC with Redis
Caching and IPC with RedisCaching and IPC with Redis
Caching and IPC with Redis
 
Advantages of Cassandra's masterless architecture
Advantages of Cassandra's masterless architectureAdvantages of Cassandra's masterless architecture
Advantages of Cassandra's masterless architecture
 
Visual Resume
Visual ResumeVisual Resume
Visual Resume
 

Semelhante a Refactoring group 1 - chapter 3,4,6

Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113SOAT
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developersStoyan Stefanov
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesAndrey Karpov
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolveXSolve
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConRafael Dohms
 
Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practicesManav Gupta
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016Manoj Kumar
 
05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboards05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboardsDenis Ristic
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsSam Hennessy
 
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Eyal Vardi
 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 TrainingChris Chubb
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRaimonds Simanovskis
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Jeff Carouth
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLsAugusto Pascutti
 

Semelhante a Refactoring group 1 - chapter 3,4,6 (20)

Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error Examples
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnCon
 
Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
Beyond java8
Beyond java8Beyond java8
Beyond java8
 
05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboards05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboards
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy Applications
 
Wakanday JS201 Best Practices
Wakanday JS201 Best PracticesWakanday JS201 Best Practices
Wakanday JS201 Best Practices
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 Training
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
 

Último

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
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
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
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
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 

Último (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
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
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
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
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
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
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 

Refactoring group 1 - chapter 3,4,6

  • 2.  Bad Smells in Code  Building Tests  Composing Methods Confidential 2
  • 3. Bad Smells in Code Who What When Where Why How Confidential 3
  • 5. ….. <app key=“ContactEmailAddress” value=“jdoe@initrode.com” /> ….. app.config (revision 1) ….. <app key=“sContactEmailAddress” value=“jdoe@initrode.com” /> ….. app.config (revision 2) Confidential 5
  • 6. // I decided not to use built-in feature to convert string to boolean if ( is_string($switch) ) { switch ($switch) { Public Function Save() As Boolean case 'false' : Try case 'down' : SaveMeeting() case 'off' : Catch ex As Exception case 'not' : Throw ex case '0' : End Try case '' : End Function $switch = false; break; default : $switch = true; break; } } <a href="/the/path/to/the/url" onclick="window.open(this.getAttribute('href'),'_blank');return false;"> link text </a> Confidential 6
  • 7. // Translates Roman Numbers to Decimal Numbers Function GetNewGuid() public string rom2num(string r) Dim cnGuid, rsGuid { if (r == "I") return "1"; Set cnGuid = CreateObject("ADODB.Connection") if (r == "II") return "2"; Set rsGuid = CreateObject("ADODB.Recordset") if (r == "III") return "3"; if (r == "IV") return "4"; cnGuid.Open = _ if (r == "V") return "5"; "Provider=SQLOLEDB.1;" + if (r == "VI") return "6"; "Data Source=<production server>; " + if (r == "VII") return "7"; "Initial Catalog=<production DB> " + if (r == "VIII") return "8"; "user id = '********';" + if (r == "IX") return "9"; "password='*********'"" // // Snipped LOTS of "code" here rsGuid.Open "SELECT newid() as Guid", cnGuid // if (r == "MMVIII") return "2008"; If Not rsGuid.EOF Then if (r == "MMIX") return "2009"; GetNewGuid = rsGuid("Guid").Value if (r == "MMX") return "2010"; End If if (r == "MMXI") return "2011"; End Function return "E"; } Confidential 7
  • 8. function checkdata() { dataok = true; t1 = document.forms.signup.firstName.value; t2 = document.forms.signup.lastName.value; t9 = document.forms.signup.locale.options.selectedIndex; t10 = document.forms.signup.currency.options.selectedIndex; t11 = document.forms.signup.timezone.options.selectedIndex; t12 = document.forms.signup.packetType.options.selectedIndex; t13 = document.forms.signup.captcha_code.value; if (t1 == '' || t2 == '„ ) { alert("Please fill-up all the fields"); dataok = false; return(dataok);} if (t4 != t5) { alert("Please enter the password again"); dataok = false; return(dataok);} if (t9 == 0) { alert("Please select a locale"); dataok = false; return(dataok);} if (t10 == 0) { alert("Please select a currency"); dataok = false; return(dataok);} return(dataok); } Confidential 8
  • 9. // Self-document code private bool TrueBecauseThisEventDoesNotRegistrictBasedUponActivityType() { return true; } private bool FalseBecauseNoActivityTypesAreAvailableForUsersWhoAreNotLoggedIn() { return false; } private bool NoActivityTypesAreAttachedToThisEvent(IEnumerable<ActivityType> activityTypes) { return activityTypes.Any() == false; } Confidential 9
  • 10. # Find the last 200 transactions logging.debug( "Finding the last 600 transactions" ) ConnMysql.query("select Id from Transactions order by ts desc limit 0,10000 ") private void EditTDemensions(bool blnYes) { //bln is the introvert of blnYes bool bln = (blnYes ? false : true); //Display or Hide buttons btnDemensionsEdit.Visible = bln; btnDemensionsSave.Visible = blnYes; btnDemensionsCancel.Visible = blnYes; } Confidential 10
  • 11.  Bad Smells in Code  Building Tests  Composing Methods Confidential 11
  • 12. Self-testing Code Confidential 12
  • 13. Without Self-testing Code Developer jobs Fix bugs Others Confidential 13
  • 14.  Bad Smells in Code  Building Tests  Composing Methods Confidential 14
  • 15. Catalog of Refactorings Composing Methods Simplifying Conditional Moving Features Expressions Between Objects Making Method Calls Organizing Data Simpler Dealing with Generalization Confidential 15
  • 16. Inline Method Extract Method Substitute Algorithm Replace Temp with Query Inline Temp Introduce Explaining Variable Replace Method with Method Object Split Temporary Variable Remove Assignments to Parameters Confidential 16

Notas do Editor

  1. Who is it about?  other presentsWhat happened?  other presentsWhen did it take place?Where did it take place?  computerWhy did it happen?  other presentsHow did it happen?  other presentsGive audience some real example indications that there is trouble that can be solved by a refactoringhttp://thedailywtf.com/Articles/FAIL-FAIL,FAIL-FAIL,FAIL-FAIL-and-More.aspxhttp://thedailywtf.com/Comments/The-Bit-Setter.aspxhttp://thedailywtf.com/Comments/Mybad.aspxhttp://thedailywtf.com/Articles/Self-Documenting.aspxhttp://thedailywtf.com/Articles/Roman-Enumeration.aspx
  2. Add a Hungarian Notation prefix to a configuration file setting, in case we weren&apos;t sure that &apos;ContactEmailAddress&apos; was a string
  3. This is to convert a string to false value and don’t want to use built-in language feature
  4. self-document code 
  5. what the link between the 3 numbers is
  6. Vaccine is kind of alike to self-testing code. It operates the system (virus) on real environment (body) in safe manner so that issues can be found at very soon
  7. Some time is spent figuring out what ought to be going on, some time is spent designing, but most time is spent debugging. Fixing the bug is usually pretty quick, but finding it is a nightmare
  8. Sample coffee script to demonstrate : extract method, introduce explaining variable, replace temp with queryStoryBoard = require &apos;./storyboard&apos;Constants = require &apos;./core/Constants&apos;class ViewerScreen extends GameScreenplayerMovesInChineseChess: (response) -&gt; if response.group == Global.GROUP.CHINESE_CHESS and response.type == Global.TYPE.PLAYER_MOVES_IN_CHINESE_CHESS_TABLE if response.code == Global.CODE.BROADCASTING_REQUEST if response.data.player == Constants.HOST_ROLE @view.startTopTimer() @view.stopBottomTimer() else response.data.player == Constants.GUEST_ROLE @view.stopTopTimer() @view.startBottomTimer()killChineseChess: (response) -&gt; if response.group == Global.GROUP.CHINESE_CHESS and response.type == Global.TYPE.KILL_CHINESE_CHESS_TABLE if response.code == Global.CODE.BROADCASTING_REQUEST data = response.data if @match.status &lt; Global.GAME_STATUS.PLAYING @msgBar.showdata.username + &apos; &apos; + Global.MUI.HAS_QUITEDhostKicksGuestOutOfChineseChess : (response) -&gt; if response.group == Global.GROUP.CHINESE_CHESS and response.type == Global.TYPE.KICKS_GUEST_OUT_OF_CHINESE_CHESS_TABLE if response.code == Global.CODE.BROADCASTING_REQUEST data = response.data @msgBar.show @match.host.username + &apos; &apos; + Global.MUI.KICKS + &apos; &apos; + @match.guest.usernamedetailsOfTableCallback: (response) -&gt; if response.group == Global.GROUP.CHINESE_CHESS and response.type == Global.TYPE.GET_DETAILS_OF_CHINESE_CHESS_TABLE if response.code == Global.CODE.SUCCESSFUL_REQUEST data = response.data if @match.status &gt;= Global.GAME_STATUS.WAITING then# ... else if response.code == Global.CODE.FAILED_REQUEST# ...