Page 244 - DCAP305_PRINCIPLES_OF_SOFTWARE_ENGINEERING
P. 244

Principles of Software Engineering



                   Notes         changes. However, the necessary condition for effective refactoring is to ensure its correctness.
                                 Any modification that may introduce new bugs to the software is more dangerous than untidy
                                 code: it requires additional time wasted on debugging the formerly working code. Unit testing
                                 is commonly suggested as the primary method of verification for refactoring. Typical test cases
                                 are used to cheek if domain-specific relations in the code persist and bug has been re-injected.
                                 Refactoring, however, aim at different goal. Although they have to preserve the software
                                 functionality (and the regression tests as well) hut they also introduce new, independent from
                                 the  business  domain  properties  that  must  be  satisfied  or  break  some  of  some  existing  ones.
                                 The considerable effort required to adjust the testing suite at every single refactoring indicates
                                 that unit tests are inappropriate for refactoring. There is a need for tests suited exclusively for
                                 refactoring that would fix the deficiencies of unit tests. In the chapter we present a concept of
                                 refactoring tests, which are intended to ease the process of testing the refactoring. These tests
                                 are created exclusively for the refactoring purposes and check the properties specific for the
                                 transformation being applied. In subsequent sections we describe the requirements for them
                                 and their suggested implementation.

                                 12.1 Meaning of Refactoring

                                 Refactoring is typically applied at the level of programs (i.e., source code). A program refactoring
                                 is a program transformation that improves the design of a program while preserving its behaviour.
                                 Martin Fowler defines a Refactoring as:

                                    •  A change made to the internal structure of software to make it easier to understand and
                                      cheaper to modify without changing its observable behaviour

                                 He then continues to define the verb to Refractor as:
                                    •  To restructure software by applying a series of Refactoring without changing its observable
                                      behaviour.
                                 Refactoring  is  an  significant  component  of  the  Extreme  Programming  software  engineering
                                 methodology. In this context, Refactoring are often associated with:
                                    •  Many small changes applied repeatedly
                                    •  A catalogue of widely discussed changes
                                    •  Explicit unit tests applied before and after each minimal change

                                    •  interactive, perhaps tool-supported, but not automated.
                                 Refactoring is the procedure of converting existing “bad” code into “good” code. It is done via
                                 the parser, the relational model, and the language module. Refactoring can rebuild the damaged
                                 structure of the code, and can even fix errors made by developers, as An interesting concept.
                                 Worth exploring is incremental Refactoring where one small portion of code is refectory at a
                                 time, leaving the rest unchanged or with only the minimum changes needed to accommodate
                                 the “bad” parts. A development method with incremental refactoring would have developers
                                 always working with hilly refectory code. That is, with code that has been machine-generated
                                 from the relational model. The developers add some new code, and immediately submit their
                                 work to the model. The model refractors the new code into the existing code and reports the
                                 result. If the new code is compatible, then the step is complete and development can continue.
                                 If not the model should explain why not and suggest alternatives, or offer an option to reactor
                                 the entire program. The key issue is that the model knows the canonical logic and uses it as
                                 a reference point before moving into new ground, in contrast with blank development where
                                 there is no stable reference point and the structure becomes a moving target.




        238                               LOVELY PROFESSIONAL UNIVERSITY
   239   240   241   242   243   244   245   246   247   248   249