Wiki Home

Refactoring


Namespace: B2B
A place to discuss refactoring:
To refactor source code is to revisit it, analyse it, and modify it to make it better.

Note we tend to think only about Refactoring source code. But refactoring can also be used on Use Cases, requirements, and indeed almost any other artifact of software development. To iterate is to refactor.
It seems to me that Refactoring (in particular refactoring source code) is, in many ways, analagous to Data Normalization. By removing duplication, reducing dependencies etc, we create code that is more resilient to change. The same effect is seen in normalization where the goal is to create a more stable transactional data model. Is anyone aware of any metrics that can be applied source code in a way analagous to how we apply 1-5th Normal Form to data models? - ?lc

I would also suggest that a major element of refactoring is abstraction, particularly in OO class design. The first iteration is often very specific to the task at hand, second and subsequent iterations see common functionality that can be abstracted to a more general method or technique that can be made specific (through specialization in subclasses) to a particular task. This is important to flexibility and re-use, and in the ability of the system to be amenable to change and modification. Steve Sawyer

In Extreme Programming, the reasons to refactor are:
  1. Make the code as simple as possible.
  2. Eliminate any duplication.
  3. Make the code as clear as possible.
  4. Enhance the flexibility of the code.

Note that, in Extreme Programming, refactoring is not about writing code in anticipation of anticipated feature changes. See Anticipatory Design
A great book dedicated to the topic is: Fowler, Martin (1999), Refactoring, Addison Wesley, ISBN 0201485672 and it's associated website at http://www.refactoring.com and more specifically the catalog at http://www.refactoring.com/catalog/index.html
.Net Refactoring Tools
Contributors: Steven Black
Burt Rosen will be doing a presentation on Re Factoring at Los Angeles on 6/14/05 and at Orange County on 6/15/05.
Another important factor to remember is testing. If you are refactoring source code, it is critical to have unit tests in place to fully test the refactored code. These tests should be in place BEFORE starting the refactoring process. Before you start changing the code, run your tests, and make sure everything is working. Then refactor. This way, if your refactoring breaks anything, the test procedures will pick up the errors.
I recommend using Fox Unit - a VFP based TDD (test driven development) tool
Burt Rosen
Are there refactoring tools for Visual FoxPro, particularily screens? I'm working with a grid of 35 columns and would like to re-order the columns in the grid itself to better. With VFP 9 class browser I tried exporting the code using the class browser and Sedna Class BrowserX and neither produces workable code. Craig Roberts

Crg, one tool in the Vfp X project that is designed to HELP Refactoring is the CodeAnalyst. The tool lets you identify various rules and then will run on a project or an individual file, identifying various problems that may exist. It is extensible and always looking for improvements. Andrew MacNeill
Category Coding Category Project Management Category Needs Refactoring
( Topic last updated: 2007.11.29 04:16:23 PM )