Скачать презентацию Refactoring An Automated Tool for the Tiger Language Скачать презентацию Refactoring An Automated Tool for the Tiger Language

6caf7c9b742128284940e665a3dcb087.ppt

  • Количество слайдов: 13

Refactoring An Automated Tool for the Tiger Language Leslie A Hensley hensleyl@papermountain. org Refactoring An Automated Tool for the Tiger Language Leslie A Hensley hensleyl@papermountain. org

What I’m Going to Show You • An example refactoring • The what, why, What I’m Going to Show You • An example refactoring • The what, why, when, and how of refactoring • My project • Refactoring resources

public class Refactoring. Example { public static void main(String args[]) { if( args. length public class Refactoring. Example { public static void main(String args[]) { if( args. length > 0 ) { String number. String = args[0]; int number = Integer. parse. Int( number. String ); String rank; switch( number case 1: rank = break; case 2: rank = break; case 3: rank = break; } ) { "first"; "second"; "third"; System. out. println( "You placed " + rank ); } else { System. out. println( "One parameter is required: 1, 2, or 3" ); } } }

public class Refactoring. Example { public static void main(String args[]) { if( args. length public class Refactoring. Example { public static void main(String args[]) { if( args. length > 0 ) { String number. String = args[0]; int number = Integer. parse. Int( number. String ); String rank; switch( number case 1: rank = break; case 2: rank = break; case 3: rank = break; } ) { "first"; "second"; "third"; System. out. println( "You placed " + rank ); } else { System. out. println( "One parameter is required: 1, 2, or 3" ); } } }

public class Refactoring. Example { public static String calculate. Rank( String number. String ) public class Refactoring. Example { public static String calculate. Rank( String number. String ) { int number = Integer. parse. Int( number. String ); String rank; switch( number case 1: rank = break; case 2: rank = break; case 3: rank = break; } ) { "first"; "second"; "third"; } public static void main(String args[]) { if( args. length > 0 ) { String number. String = args[0]; String rank = calculate. Rank( number. String ); System. out. println( "You placed " + rank ); } else { System. out. println( "One parameter is required: 1, 2, or 3" ); } } }

What is Refactoring • Refactoring(noun): a change made to the internal structure of software What is Refactoring • Refactoring(noun): a change made to the internal structure of software to make it easier to understand cheaper to modify without changing its observable behavior. • Refactor(verb): to restructure software by applying a series of refactorings without changing its observable behavior.

The result of this is that the system is always as simple as we The result of this is that the system is always as simple as we can make it, which means we can understand it better, which means we can change it more rapidly while keeping it reliable. Try it, you'll like it. . . --Ron Jeffries

Why Should You Refactor • Refactoring improves the design of software. • Refactoring makes Why Should You Refactor • Refactoring improves the design of software. • Refactoring makes software easier to understand. • Refactoring helps you find bugs. • Refactoring helps you program faster.

When Should You Refactor • • Refactor when you add duplicate code. Refactor when When Should You Refactor • • Refactor when you add duplicate code. Refactor when you add functionality. Refactor when you need to fix a bug. Refactor as you do a code review.

How Should You Refactor • • • Refactor mercilessly Refactor in small discrete steps How Should You Refactor • • • Refactor mercilessly Refactor in small discrete steps Test after each step Refactor in pairs Don’t mix with adding functionality or fixing a defect

Automated Refactoring [The Smalltalk Refactoring Browser] completely changes the way you think about refactoring. Automated Refactoring [The Smalltalk Refactoring Browser] completely changes the way you think about refactoring. All those niggling little “well, I should change this name but…” thoughts go away, because you just change the name because there is always a single menu item to just change the name. ” --Kent Beck

A Refactoring Tool for Tiger • The language is used in some compiler classes A Refactoring Tool for Tiger • The language is used in some compiler classes at UK • Implements the Extract Method refactoring • I practiced what I am preaching during its implementation.

Refactoring Resources • Fowler, Martin. Refactoring: Improving the Design of Existing Code. 1999. • Refactoring Resources • Fowler, Martin. Refactoring: Improving the Design of Existing Code. 1999. • The Extreme Programming wiki – http: //www. c 2. com • JUnit – http: //www. junit. org • This presentation – http: //www. papermountain. org