60 likes | 158 Views
HangMan PBL - Refactoring. Use your updated (best) version of Hangman ( with a dictionary of words ). Detect potential problems : Metric values out of bounds ? ( Your code should pass this ?)
E N D
HangMan PBL - Refactoring • Use yourupdated (best) version of Hangman (with a dictionary of words). • Detectpotentialproblems: • Metric values out of bounds ? (Your code shouldpassthis?) • Poorobjectoriented design thatgives off badsmells? (Your code probablywontpassthis?) • Prepare a refactoring: • Check the tests for the code to berefactored – • Are all tests passed? • Is the coverage good (100%)? • Is the documentation good? • Submit/savecurrent version beforeproceeding • Run the refactoring: • Does the Eclipse IDE provide a refactoring for you to (partially) correct the problem? • YES – use it and re-run application tests • NO – check if someothertoolexists • YES – test the refactoringbefore use, use it and re-run application tests • NO – check if somehelp for manualrefactoring • YES –test the refactoringbefore use, use it and re-run application tests • NO – proceedwith care • Check the problems have been removed/reduced. CSC7302: Testing & Metrics
HangMan PBL - Refactoring • Detectpotentialproblems: • Useful plug-ins: • Metric values out of bounds ? • This metrics plugin calculates various code and design metrics for Java projects. In addition to metrics such as McCabe cyclomatic complexity and the dependency metrics of Robert Martin and many others, it also includes a graphical dependency analysis tool based on the dynamic hyperbolic graphing package TouchGraph. • You shouldalready have thisinstalled CSC7302: Testing & Metrics
HangMan PBL - Refactoring • Detectpotentialproblems: • Useful plug-ins: • Poorobjectoriented design thatgives off badsmells? • inCodeis source code analyzer that provides a continuous detection of several well-known design flaws (i.e. God Class, Feature Envy, Data Class and Significant Duplication) that are described in the "Object-Oriented Metrics in Practice" book (Springer, 2006). Furthermore the tool provides three helpful visualisationsof (i) the entire system (System Complexity View), (ii) classes (Class Blueprint)and (iii) methods (Method Interaction). • You can install this from: http://www.intooitus.com/products/incode • See: inCode: ContinuousQualityAssessment and Improvement, Radu Marinescu, George Ganea and IoanaVerebi, LOOSE ResearchGroup, PolitehnicaUniversity of Timis¸oara, Romania CSC7302: Testing & Metrics
HangMan PBL - Refactoring • Prepare a refactoring: • Check the tests for the code to berefactored – • Are all tests passed? • Is the coverage good (100%)? • I use 2 coveragetools/plugins: • EclEmma - http://www.eclemma.org/ • DJunit - http://works.dgic.co.jp/djunit/ • Is the documentation good? • I hopeyou are usingJavadocs? • Submit/savecurrent version beforeproceeding • I hopeyou are using version control (svn, cvs?) TO DO: install and executethesecoveragetools on yourhangman code/tests CSC7302: Testing & Metrics
HangMan PBL - Refactoring • Run the refactoring: • Does the Eclipse IDE provide a refactoring for you to (partially) correct the problem? • YES – use it and re-run application tests • NO – check if someothertoolexists • YES – test the refactoringbefore use, use it and re-run application tests • NO – check if somehelp for manualrefactoring • YES –test the refactoringbefore use, use it and re-run application tests • NO – proceedwith care Try and refactoryour code (in whateverwayyouwish) sothatyou are happy with the quality of the design. CSC7302: Testing & Metrics
HangMan PBL - Refactoring Check the problems have been removed/reduced. • It isalmost certain thatyouwillneed to repeat the refactoring multiple times beforeyou arrive at an acceptable design/implementation. • Note thatyoumay have to compromise withcomplexsystems – itmay not be possible/easy to pass all metric tests and/or getrid of all badsmells. • It is best to stop refactoringwhenit looks likeyouwillbegoing round in circles. • Don’tforget to submit/saveany version thatimproves the system whilststill passing all the tests (with good test coverage) • Once you are happy withyourHangman solution wewill move onto the next stage of development: usingdictionariesfrom (standardised) files. • This willlead us to examine: • Coupling and cohesion • Integrationtesting • Regressiontesting CSC7302: Testing & Metrics