SlideShare uma empresa Scribd logo
1 de 8
Baixar para ler 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

Mais conteúdo relacionado

Semelhante a 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
 

Mais de 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
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
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
 

Mais de 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
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
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, ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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
 

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