Refactoring


Producing software is a very complex process that takes a considerable time to evolve. To help with development there are a number of software lifecycle models which aid to manage this process.A model breaks down the problem into smaller more manageable parts that are individually _ developed iteratively until all the requirements are met.

However using such models do not take into consideration some reality factors that have direct influence on developing software. These factors are, the requirements changing to accommodate clients' needs, new functionality arises, pressures of meeting deadlines and the evolution of developers changing have an over all effect on the whole quality of the system design. These are some of the problems that relate to maintaining software. Software maintenance is described formally as "the process of modifying a software system or component after delivery to correct faults, improve performance or other attributes, or adapt to a changed environment".

Software maintenance can take up to 50% of the overall development costs of producing software. Boehm carried out a study in 1975 on a project being developed and concluded that it cost $30 per line of code during development which increased to $4,000 per line for maintenance costs.

One of the main attributes to these high costs is poorly designed code, which makes it difficult for developers to understand the system even before considering implementing new code. Understanding a system requires the "Software engineer to extract high-level information from low
level code". These high level abstractions use approximations to produce abstract models of the underlying system. These models will produce a limited level of under-standing of the system through information that has been lost in using the approximations to produce these models.

This makes the design of code an increasingly important part of the overall development I of software. Refactoring "is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure" Refactoring can have a direct influence on reducing the cost of software maintenance through changing the internal structure of the code to increase the design which helps the present and future developers evolve and understand the system. The aim of this report is to outline the importance of refactoring through a comprehensive literature review and also identifying possible research questions, which could be considered for future work.

Refactoring is relatively a new area of research and so is not well defined. There are a vast number of definitions for refactoring, most of them are mentioned below. This list is quite large to correlate to the many different areas which refactoring covers.

Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. Its heart is a series of small behavior preserving transformations. Each transformation (called a 'refactoring') does little, but a sequence of transformations can produce a significant restructuring. Since each refactoring is small, it's less likely to go wrong. The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring.

In software engineering, "refactoring" source code means modifying it without changing its behavior, and is sometimes informally referred to as "cleaning it up". Refactoring neither fixes bugsunderstandability of the code and changes its internal structure and design, and removes dead code, to make it easier to comprehend, more maintainable and amenable to change. Refactoring is usually motivated by the difficulty of adding new functionality to a program or fixing a bug in it. nor adds new functionality, though it might precede either activity. Rather it improves the

In extreme programming and other agile methodologies, refactoring is an integral part of the software development cycle: developers first write tests, then write code to make the tests pass, and finally refactor the code to improve its internal consistency and clarity. Automatic unit testing ensures that refactoring preserves correctness.

Code smells are a heuristic to indicate when to refactor, and what specific refactoring techniques to use.

An example of a trivial refactoring is to change a variable name into something more meaningful, such as from a single letter 'i' to 'interestRate' (see: identifier naming convention). A more complex refactoring is to turn the code within an if block into a subroutine. An even more complex refactoring is to replace an if conditional with polymorphism.

While "cleaning up" code has happened for decades, the key insight in refactoring is to intentionally "clean up" code separately from adding new functionality, using a known catalogue of common useful refactoring methods, and then separately testing the code, to ensure that existing behavior is preserved. The new aspect is explicitly wanting to improve an existing design without altering its intent or behavior.

Some refactoring methods face challenges in being used. Refactoring the business layer stored in a database schema is difficult or impossible, because of schema transformation and data migration that must occur while system may be under heavy use. Finally, refactoring that affects an interface can cause difficulties unless the programmer has access to all users of the interface. For example, a programmer changing the name of a method in an interface must either edit all references to the old name throughout the entire project or maintain a stub with the old method name. That stub would then call the new name of the method.

Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior. Refactoring (verb): to restructure software by applying a series of Refactoring without changing its observable behavior. Refactoring is the process of taking an object design and rearranging it in various ways to make the design more flexible and/or reusable. There are several reasons you might want to do this, efficiency and maintainability being probably the most important.

To refractor programming code is to rewrite the code, to "clean it up" Refactoring is the moving of units of functionality from one place to another in your program.

Refactoring has as a primary objective, getting each piece of functionality to exist in exactly one place in the software Refactoring is the process of taking an object design and rearranging it in various ways to make the design more flexible and/or reusable. There are several reasons you might want to do this, efficiency and maintainability being probably the most important.