SlideShare a Scribd company logo
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

Similar to tutorial4x4

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?
Believ-In Technologies
 
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
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Oracle fusion crm an overview
Oracle fusion crm an overviewOracle fusion crm an overview
Oracle fusion crm an overview
Naga Chokkanathan
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
pratik tambekar
 
Oozie @ Riot Games
Oozie @ Riot GamesOozie @ Riot Games
Oozie @ Riot Games
Matt Goeke
 
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
Alexander Lisachenko
 

Similar to tutorial4x4 (7)

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 – INS0
tutorialsruby
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
tutorialsruby
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
tutorialsruby
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
tutorialsruby
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
tutorialsruby
 
CSS
CSSCSS
CSS
CSSCSS
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
tutorialsruby
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
tutorialsruby
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 

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

Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 

Recently uploaded (20)

Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 

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