Rational Refactoring driven by Semantics

18. December 2006 10:18 by CarlosLoria in General  //  Tags:   //   Comments (0)

In this introductory post, we motivate some basic notions and set a context with respect to the problem of performing computer aided refactoring; we want to pay special attention to refactoring of Web pages as a target and look for implementation paths as a systematic process, subject that we present in a white paper available for the interested reader.

Refactoring is understood as any form of software transformation which is performed with the purpose of improving quality attributes of some piece of software without changing its originally intended behavior; it is used typically for accomplishing more readability and better understanding. A refactoring step should be relatively small and specific, so that is easily testable, for instance trough unit-testing; however such steps can be composed for achieving a broader transformation goal. Software refactoring can be effectively used to interleave "actual" development steps with small and disciplined (e.g. preventive and perfective) steps of maintenance; by this way, refactoring makes feasible to reach higher levels of software quality at the long term without necessarily disturbing programming productivity at the short term.

Refactoring  tools are nowadays hosted in many IDEs for popular programming languages for tasks like consistently renaming of an identifier, for performing method extraction and method pull-up/down operations, among some others. The IDE usually gives facilities to apply the transformation in a mechanical and safe way; the user is the driver the IDE is the refactoring vehicle in such a case. In some cases, the refactoring operations are predetermined, so the programmer has no easy way to create and compose his/her owns transformations, for instance defining own made set of rules for naming conventions or criteria for diagnosing aspects of design quality, those eventually deserving refactoring efforts.
Beyond the nice possibility of programming refactoring, let us suppose we also are interested in a more automated and flexible form of refactoring, namely, one that assists by the detection of refactoring opportunities and  anticipates the benefits of applying associated transformations.
Although such a facility would be certainly useful, we can easily realize that there can be a lot of opportunities of different nature for identifying a valuable refactoring task. So, if we think of such a process as a search problem, we rapidly need to accept that the search space can be big and heterogeneous with respect to the nature and goals a programmer may attempt to accomplish through the one or the other kind of refactoring path. Those goals may also depend on the kind of software element we are interested in.

With this general context in mind, we consider one specific case, namely the refactoring of web pages; for such purpose we have developed a white paper, where we elaborate on standard reasoning strategies envisioning the requirements for an automated tool which aids at the task of systematically refactoring web pages. Our presentation -that we name rational refactoring- is more intuitive and practical than formal, we focus on the central value of employing a semantically based approach for driving the process and expose justifications in terms of the some potential advantages we may obtain when we are considering computer aided refactoring of web pages, specifically. We use some ASP.NET facilities for illustrations purposes. The white paper is available here.