Industrial XP -> Refactoring

Refactoring

Improving the design of existing code

The following text comes from Joshua Kerievsky's book, Refactoring to Patterns.

What Is Refactoring?

A refactoring is a 揵ehavior-preserving transformation,?or, as Martin Fowler defines it, 揳 change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior.?[F, page 53].

When we refactor, we relentlessly poke and prod our code to improve its design. Such improvements may involve something as small as changing a variable name or as large as unifying two hierarchies. Refactoring involves the removal of duplication, the simplification of complex logic and the clarification of unclear code.

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
--Martin Fowler, from Refactoring: Improving the Design of Existing Code

To refactor safely, you must either manually test that your changes didn't break anything or you must run automated tests. You will have more courage to refactor and be more willing to try experimental designs if you can quickly run automated tests to confirm that your code still works.

We refactor in small steps to prevent ourselves from introducing defects. Most refactorings take seconds or minutes to perform. Some large refactorings can require a sustained effort for days, weeks or months until a transformation has been completed. Even large refactorings are implemented in smell steps.

It's best to refactor continuously, rather than in phases. When you see code that needs improvement, improve it. On the other hand, if your manager needs you to finish a feature before they demo the software at an impromptu morning meeting, finish the feature and refactor it later. Business is well served by continuous refactoring, yet the practice of refactoring must co-exist harmoniously with business priorities.

Further Reading

Refactoring: Improving the Design of Existing Code by Martin Fowler.
Martin's website.
Refactoring to Patterns by Joshua Kerievsky
Refactoring YahooGroup

Industrial XP logo
 
Values & Practices
?/b>
?/b>
?/b> Continuous Risk Management
?/b> Project Chartering
?/b> Project Community
?/b> Test-Driven Management
?/b> Sustainable Pace
?/b> Planning Game
?/b> Storytelling
?/b> Storytesting
?/b> Frequent Releases
?/b> Small Teams
?/b> Sitting Together
?/b> Continuous Learning
?/b> Iterative Usability
?/b> Evolutionary Design
?/b>
?/b> Refactoring
?/b> Domain-Driven Design
?/b> Pairing
?/b> Continuous Integration
?/b> Collective Ownership
?/b> Coding Standard
?/b> Retrospectives



 
Send mail to webmaster@industriallogic.com with questions or comments about this web site.
Copyright ?2004 Industrial Logic, Inc. All Rights Reserved.
万丰彩票 临海市 湖北省 钟祥市 大同市 兰溪市 湘潭市 松滋市 铁力市 彭州市 厦门市 宜春市 邹城市 彭州市 山东省 金昌市 平度市 海南省 双滦区 忻州市 葫芦岛市 十堰市 平度市 潞城市 临沂市 阜新市 普兰店市 汉川市 兴城市 都匀市 枣庄市 安达市 烟台市 高邮市 梅河口市 江油市 白银市 丰城市 孝义市 石首市 池州市 葫芦岛市 福建省 金华市 梅河口市 胶州市 上虞市 大石桥市 江阴市 吉首市 大庆市 铁力市 深州市 山西省 厦门市 项城市 永州市 原平市 明光市 耒阳市