SlideShare a Scribd company logo
1 of 8
Download to read offline
Last lecture…
                                                                             On refactoring
                                                           • We explained what is refactoring, what is
                                                             software refactoring
                     Tutorial 4                            • How are they related to other restructuring
                More on Refactoring                          techniques?
                                                           • Examples of refactoring
              How to refactoring unstructured code?
                                                           • Refactoring structured source code into
               How to apply refactoring in Eclipse?
                                                             goal models
                                                           • …

Spring 2005          ECE450H1S   Software Engineering II   Spring 2005     ECE450H1S   Software Engineering II




                                                                           1. Refactoring an
                           Today…
                                                                         unstructured program
1. How to refactoring unstructured code into               • The subject is called “Squirrel Mail”
   goal models?                                            • It has 70 KLOC
2. How to use Eclipse to do refactoring?                   • Developed in PHP
3. Discussions                                               Function call
                                                             Foo.php: <?php include(“bar.php”) ?>
4. Relation to your course project                         • Why it is unstructured?
                                                             Foo.php: <a href=“bar.php”/>
                                                                       <a href=“moo.php”/>
                                                                       <?php echo “I won super 7!” ?>
                                                             Any idea?
Spring 2005          ECE450H1S   Software Engineering II   Spring 2005     ECE450H1S   Software Engineering II
Why a PHP program is
                                                                                                     The process
                   unstructured?
• Every Hyperlink generated from the PHP                            • Structured program is easier to understand
  is an “exit” in the current PHP program                                           /HJDF
                                                                                  VRXUFH FRGH
                                                                                                    ([WUDFW
                                                                                                   0HWKRGV
                                                                                                                      5HIDFWRUHG
                                                                                                                     VRXUFH FRGH
                                                                                                   5HIDFWRU
• It may call other PHP routines, other web
                                                                                                             HV                        1R             RQVWUXFW
  pages, etc. when user click at them                                                                               ,V VWUXFWXUHG
                                                                                                                                                     +DPPRFN JUDSK


• Non-deterministic, how could you tell
                                                                                                                                                     ([WUDFW
  which link will the user click?                                          $67
                                                                        DQQRWDWHG  3DUVH
                                                                                                    6WUXFWXUHG
                                                                                                     SURJUDP
                                                                                                                    (OLPLQDWH
                                                                                                                      *272
                                                                                                                                     +LJKOHYHO
                                                                                                                                     6WDWHFKDUW
                                                                                                                                                     6WDWHV
                                                                                                                                                   7UDQVLWLRQV
                                                                                                                                                                 6WDWHFKDUWV
                                                                        *RDO JUDSK
5HIDFWRULQJ
• Even “go back” button will change the                                 5HVWUXFWXUH

  behaviour of the program                                                                       7HVW WR                                $QDO]H 4XDOLW      *RDO 0RGHO
                                                                                                                      *RDO 0RGHO
                                                                        *RDO 0RGHO               LGHQWLI                                PHWULFV WR LGHQWLI        ZLWK
• So …                                                                                            1)5V
                                                                                                                      ZLWK 1)5V
                                                                                                                                             VRIWJRDOV            6RIWJRDOV


Spring 2005          ECE450H1S   Software Engineering II            Spring 2005                  ECE450H1S                 Software Engineering II




              1.1 Refactoring based on
                                                                                                             Example
                     comments
                                                                       /** Path for SquirrelMail required files. */
                                                                       define(‘SM_PATH’,’../’);
HQW            WKH IROORZLQJ GRHV 6                                  require_once($SM_PATH . ‘functions/strings.php’);
U            6, 2
UHIDFWRUHG       require_once($SM_PATH . ‘config/config.php’);
                                                                       require_once($SM_PATH . ‘functions/i18n.php’);
H[LW          6, 2
6, 2
require_once($SM_PATH . ‘functions/plugin.php’);
                                                                       require_once($SM_PATH . ‘functions/constants.php’);
               RWKHU …                                               require_once($SM_PATH . ‘functions/page_header.php’);
                                                                       require_once($SM_PATH . ‘functions/html.php’);
       9DULDEOHV GHILQHG EHIRUH WKH HQWU RI WKH EORFN                 require_once($SM_PATH . ‘functions/global.php’);
               , ,∪,
∩ ^ Y _ GHI Y S
∧ S ∠ S HQWU ` ≠ φ        require_once($SM_PATH . ‘functions/imap_general.php’);
       9DULDEOHV GHILQHG LQ WKH EORFN WKDW ZLOO EH XVHG DIWHU WKH
       H[LW
              2 2∪2

More Related Content

Viewers also liked

Technology Presentation
Technology PresentationTechnology Presentation
Technology PresentationDarrell3838
 
DI Powerpoint
DI PowerpointDI Powerpoint
DI Powerpointely2boys
 
La cop21 vue par le web social
La cop21 vue par le web socialLa cop21 vue par le web social
La cop21 vue par le web socialTBWA\Corporate
 
20 town appeal appendix b
20 town appeal appendix b20 town appeal appendix b
20 town appeal appendix bKevin Sitlick
 
SD25LD(JP)(碟煞+陶瓷汽缸)/零件型錄
SD25LD(JP)(碟煞+陶瓷汽缸)/零件型錄SD25LD(JP)(碟煞+陶瓷汽缸)/零件型錄
SD25LD(JP)(碟煞+陶瓷汽缸)/零件型錄Rex Cheng
 
'NEW Science project 9.19.2011 By Tony Lee
'NEW Science project 9.19.2011 By Tony Lee'NEW Science project 9.19.2011 By Tony Lee
'NEW Science project 9.19.2011 By Tony Leetummyblast
 
Mercado de oficinas Lima 2014 Q4 - colliers
Mercado de oficinas Lima 2014 Q4 - colliersMercado de oficinas Lima 2014 Q4 - colliers
Mercado de oficinas Lima 2014 Q4 - colliersWorld Office Forum
 
Grille 19 Billboard Final
Grille 19 Billboard FinalGrille 19 Billboard Final
Grille 19 Billboard FinalAlexander Kotz
 
morgan stanley Annual Reports 2001
morgan stanley  Annual Reports 2001 morgan stanley  Annual Reports 2001
morgan stanley Annual Reports 2001 finance2
 
Amo absolute encoder_catalog
Amo absolute encoder_catalogAmo absolute encoder_catalog
Amo absolute encoder_catalogElectromate
 
Carta Comercial
Carta ComercialCarta Comercial
Carta ComercialJonathan
 
Marmara Sea: Çınarcık Basin
Marmara Sea: Çınarcık BasinMarmara Sea: Çınarcık Basin
Marmara Sea: Çınarcık BasinAli Osman Öncel
 

Viewers also liked (16)

KotzLogo
KotzLogoKotzLogo
KotzLogo
 
Technology Presentation
Technology PresentationTechnology Presentation
Technology Presentation
 
DI Powerpoint
DI PowerpointDI Powerpoint
DI Powerpoint
 
La cop21 vue par le web social
La cop21 vue par le web socialLa cop21 vue par le web social
La cop21 vue par le web social
 
deed_of_trust
deed_of_trustdeed_of_trust
deed_of_trust
 
20 town appeal appendix b
20 town appeal appendix b20 town appeal appendix b
20 town appeal appendix b
 
SD25LD(JP)(碟煞+陶瓷汽缸)/零件型錄
SD25LD(JP)(碟煞+陶瓷汽缸)/零件型錄SD25LD(JP)(碟煞+陶瓷汽缸)/零件型錄
SD25LD(JP)(碟煞+陶瓷汽缸)/零件型錄
 
'NEW Science project 9.19.2011 By Tony Lee
'NEW Science project 9.19.2011 By Tony Lee'NEW Science project 9.19.2011 By Tony Lee
'NEW Science project 9.19.2011 By Tony Lee
 
Auto Finance Benchmark
Auto Finance BenchmarkAuto Finance Benchmark
Auto Finance Benchmark
 
Mercado de oficinas Lima 2014 Q4 - colliers
Mercado de oficinas Lima 2014 Q4 - colliersMercado de oficinas Lima 2014 Q4 - colliers
Mercado de oficinas Lima 2014 Q4 - colliers
 
Grille 19 Billboard Final
Grille 19 Billboard FinalGrille 19 Billboard Final
Grille 19 Billboard Final
 
2013-2014 Educator guide
2013-2014 Educator guide2013-2014 Educator guide
2013-2014 Educator guide
 
morgan stanley Annual Reports 2001
morgan stanley  Annual Reports 2001 morgan stanley  Annual Reports 2001
morgan stanley Annual Reports 2001
 
Amo absolute encoder_catalog
Amo absolute encoder_catalogAmo absolute encoder_catalog
Amo absolute encoder_catalog
 
Carta Comercial
Carta ComercialCarta Comercial
Carta Comercial
 
Marmara Sea: Çınarcık Basin
Marmara Sea: Çınarcık BasinMarmara Sea: Çınarcık Basin
Marmara Sea: Çınarcık Basin
 

Similar to tutorial4x4

Similar to tutorial4x4 (9)

Opnfv primer how to get into opnfv
Opnfv primer  how to get into opnfv Opnfv primer  how to get into opnfv
Opnfv primer how to get into opnfv
 
React. Flux. Redux
React. Flux. ReduxReact. Flux. Redux
React. Flux. Redux
 
Node.Js Vs PHP: Which is Likely a Better Server Side Environment?
Node.Js Vs PHP: Which is Likely a Better Server Side Environment?Node.Js Vs PHP: Which is Likely a Better Server Side Environment?
Node.Js Vs PHP: Which is Likely a Better Server Side Environment?
 
Wt unit 4 server side technology-2
Wt unit 4 server side technology-2Wt unit 4 server side technology-2
Wt unit 4 server side technology-2
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Oracle fusion crm an overview
Oracle fusion crm an overviewOracle fusion crm an overview
Oracle fusion crm an overview
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Oozie @ Riot Games
Oozie @ Riot GamesOozie @ Riot Games
Oozie @ Riot Games
 
Weaving aspects in PHP with the help of Go! AOP library
Weaving aspects in PHP with the help of Go! AOP libraryWeaving aspects in PHP with the help of Go! AOP library
Weaving aspects in PHP with the help of Go! AOP library
 

More from tutorialsruby

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 

More from tutorialsruby (20)

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Recently uploaded

Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxMasterG
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfAnubhavMangla3
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch TuesdayIvanti
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimaginedpanagenda
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 

Recently uploaded (20)

Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 

tutorial4x4

  • 1. Last lecture… On refactoring • We explained what is refactoring, what is software refactoring Tutorial 4 • How are they related to other restructuring More on Refactoring techniques? • Examples of refactoring How to refactoring unstructured code? • Refactoring structured source code into How to apply refactoring in Eclipse? goal models • … Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II 1. Refactoring an Today… unstructured program 1. How to refactoring unstructured code into • The subject is called “Squirrel Mail” goal models? • It has 70 KLOC 2. How to use Eclipse to do refactoring? • Developed in PHP 3. Discussions Function call Foo.php: <?php include(“bar.php”) ?> 4. Relation to your course project • Why it is unstructured? Foo.php: <a href=“bar.php”/> <a href=“moo.php”/> <?php echo “I won super 7!” ?> Any idea? Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II
  • 2. Why a PHP program is The process unstructured? • Every Hyperlink generated from the PHP • Structured program is easier to understand is an “exit” in the current PHP program /HJDF VRXUFH FRGH ([WUDFW 0HWKRGV 5HIDFWRUHG VRXUFH FRGH 5HIDFWRU • It may call other PHP routines, other web HV 1R RQVWUXFW pages, etc. when user click at them ,V VWUXFWXUHG +DPPRFN JUDSK • Non-deterministic, how could you tell ([WUDFW which link will the user click? $67 DQQRWDWHG 3DUVH 6WUXFWXUHG SURJUDP (OLPLQDWH *272 +LJKOHYHO 6WDWHFKDUW 6WDWHV 7UDQVLWLRQV 6WDWHFKDUWV *RDO JUDSK
  • 3. 5HIDFWRULQJ • Even “go back” button will change the 5HVWUXFWXUH behaviour of the program 7HVW WR $QDO]H 4XDOLW *RDO 0RGHO *RDO 0RGHO *RDO 0RGHO LGHQWLI PHWULFV WR LGHQWLI ZLWK • So … 1)5V ZLWK 1)5V VRIWJRDOV 6RIWJRDOV Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II 1.1 Refactoring based on Example comments /** Path for SquirrelMail required files. */ define(‘SM_PATH’,’../’); HQW WKH IROORZLQJ GRHV 6 require_once($SM_PATH . ‘functions/strings.php’); U 6, 2
  • 4. UHIDFWRUHG require_once($SM_PATH . ‘config/config.php’); require_once($SM_PATH . ‘functions/i18n.php’); H[LW 6, 2
  • 6. require_once($SM_PATH . ‘functions/plugin.php’); require_once($SM_PATH . ‘functions/constants.php’); RWKHU … require_once($SM_PATH . ‘functions/page_header.php’); require_once($SM_PATH . ‘functions/html.php’); 9DULDEOHV GHILQHG EHIRUH WKH HQWU RI WKH EORFN require_once($SM_PATH . ‘functions/global.php’); , ,∪,
  • 7. ∩ ^ Y _ GHI Y S
  • 8. ∧ S ∠ S HQWU ` ≠ φ require_once($SM_PATH . ‘functions/imap_general.php’); 9DULDEOHV GHILQHG LQ WKH EORFN WKDW ZLOO EH XVHG DIWHU WKH H[LW 2 2∪2
  • 9. ∩^ Y _ XVH Y S
  • 10. ∧ S H[LW ∠ S ` ≠ φ $SM_PATH=set_path (); Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II
  • 11. Further … 1.2 Convert into statechart ?php /* login.php */ • Statecharts concisely describe behaviour of a system. $SM_PATH=set_path (); $SM_lang=setup_language(); • No comments now, but we need to understand its $base_uri = findout_base_URI(); $logindisabled = detect_imap_server($base_uri); behaviour, therefore … if ($logindisabled) { explain_situation(); $SM_PATH is exit; undefined } do_hook(‘login_cookie’); $header =onload_function(“redirect.php”); /set_path display_header($header); $SM_PATH=set_path (); /set_path load_theme($theme[$theme_default]); do_hook('login_top'); show_logo(); show_form($loginname, $mailto, $key); $SM_PATH is $SM_PATH set do_hook('login_form'); do_hook('login_bottom'); ? Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II 1.4 Put it together …the high-level statechart of the 1.3 Statechart refactoring unstructured program Extract Method - Extract States and Transitions based on Hammock graphs What’s new here? You are refactoring behaviour rather than structures! Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II
  • 12. 1.4 Now convert statechart back 1.4 Eliminate GOTO’s into a program with GOTO’s • FORTRAN • FPT (Fortran parallelizing transformer, developed at ELIS, Ghent call EnterURL University, Belgium) 10 call Login • Result of goto elimination: if (wrongIMAP) goto 30 CALL EnterURL 20 call ShowForm REPEAT if (wrongKey) goto 20 REPEAT call EnterForm CALL Login IF (.not.wrongIMAP) THEN if (wrongForm) goto 30 REPEAT call StartWebMail CALL ShowForm if (loggedOut) goto 10 UNTIL (.not.wrongKey) if (expired) goto 10 CALL EnterForm IF(.not.wrongForm)THEN call Send CALL StartWebmail Stop ENDIF 30 call ReportError ENDIF call GoBack UNTIL (.not.loggedOut.or .not.expired.or.wrongIMAP .or.wrongForm) IF(wrongIMAP.or.wrongForm) goto 10 THEN end CALL ReportError • Rule of thumb: every state is a basic block; adding a label to states with CALL GoBack ENDIF multiple incoming transitions; adding GOTO statements for all outgoing UNTIL (.not.wrongIMAP.and.not.wrongForm) transitions except one; line-up the basic blocks CALL Send END Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II 1.5 Turning structured program into 1.6 Turning it into “pure” goal an annotated goal model model (AND/OR graph) •call A … call B AND A B •if (x) then … call A if(x) OR if(!x) else A B call B end if … [topic] AND •call A A repeat until (s) B repeat … call C OR until s s C call B Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II
  • 13. 1.7 Introducing softgoals 2. How to refactoring in Eclipse • Identify NFRs • If you are developing in Java, you are LUCKY! • Add softgoals to • The Eclipse IDE, JBuilder IDE are very categorize why comprehensive there are the • Refactoring was developed in Smalltalk, now NFRs moved to Java in Eclipse, it has been told in C# • If possible, one for Visual Studio, etc. can measure the • It should not be long to see open-source degree of programming languages to have them satisfaction for supported, such as PHP the softgoals • Examples, developed by Jing Su Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II Example 1 – extract method void f() { void f() { ... ... // Compute score computeScore(); score = a * b + c; } score -= discount; } void computeScore() { score = a * b + c; score -= discount; } Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II
  • 14. Enter a name according to the comment Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II Example 2 – move method class Jar { class Jar { ... bool isFragile() { } switch(material) { class RoboPacker { case GLASS: return true; private bool isFragile(Jar foo) { case WOOD: return true; switch(foo.material) { case TIN: return false; case GLASS: return true; }}} case WOOD: return true; class RoboPacker { case TIN: return false; private bool isFragile(Jar foo) { } return foo.isFragile(); } } } } Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II
  • 15. Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II Example 3 – lift method class Jar { class Jar { bool isFragile() { bool isFragile() { switch(material) { return material.isFragile(); case GLASS: }} // complex glass calculation case WOOD: interface Material { ... } // complex wood calculation class GlassMaterial:Material { ... } case TIN: class WoodMaterial:Material { ... } // complex tin calculation class TinMaterial:Material { ... } }}} Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II
  • 16. 3. Think about these … 4. Relation to your project 1. How to extend refactoring tool support to • Opportunities: – You may add junit test cases to the code base to other programming languages such as reveal bugs (publish it to the bug tracking system) PHP? and fix them (+5%) – You may apply design patterns, refactoring 2. Can you extend refactoring to techniques on this legacy code base, showing as an improved complexity metrics (+2.5%) documents, such as in various formats: – You may tune the performance of the system to diagrams, textual, xml, etc.? speed up the display, load/save for scalable graphs (+2.5%) 3. How can know a function is NFR? • Don’t forget your major project task (up to Can you measure the impact of a NFR 100%!) – To study the editor methods in the OpenOME and on a quality attribute? adapt them to the OmniGraphEditor web service. Spring 2005 ECE450H1S Software Engineering II Spring 2005 ECE450H1S Software Engineering II