SlideShare una empresa de 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

Más contenido relacionado

La actualidad más candente

Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bits
Chris Saylor
 

La actualidad más candente (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
 

Destacado

Soal quizz lp3i manyar-corel draw
Soal quizz lp3i manyar-corel drawSoal quizz lp3i manyar-corel draw
Soal quizz lp3i manyar-corel draw
prihardini
 
Building creative expression
Building creative expressionBuilding creative expression
Building creative expression
richardofaustin
 
Visual Resume
Visual ResumeVisual Resume
Visual Resume
Criser01
 

Destacado (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
 

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

JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
Stoyan Stefanov
 
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
 
Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
Manav Gupta
 

Similar 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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

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 del 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# ...