• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Refactoring, A First Example
 

Refactoring, A First Example

on

  • 1,322 views

 

Statistics

Views

Total Views
1,322
Views on SlideShare
1,320
Embed Views
2

Actions

Likes
1
Downloads
30
Comments
0

2 Embeds 2

http://www.slideshare.net 1
http://www.linkedin.com 1

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • 08/31/09 06:39 © 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

Refactoring, A First Example Refactoring, A First Example Presentation Transcript

  • Refactoring, a First Example Vorleak Chy (vorleak.chy@gmail.com) Software Engineer Yoolk Inc http://groups.google.com/group/khmertech/
  • Before Refactoring
    • Unreadable code
    • Duplicated code
    • Complex code
    • Hard to modify
  • After Refactoring
    • Easier to understand
    • Cheaper to modify
    • Clean code
    • Better code
  • Introduction
    • What is Refactoring?
    • Why Refactor?
  • What is Refactoring?
    • The process of changing a software system in such a way that it does not alter the external behaviour of the code, yet improves its internal structure .
    • Fowler, et al., Refactoring, 1999.
  • Why Refactor?
    • The reality
      • Extremely difficult to get the design “right” the first time
      • Hard to fully understand the problem domain
      • Hard to understand user requirements, even if the user does!
      • Hard to know how the system will evolve in five years
      • Original design is often inadequate
      • System becomes brittle over time, and more difficult to change
  • Why Refactor? (Cont.)
    • Refactoring helps you to
      • Manipulate code in a safe environment (behavior preserving)
      • Recreate a situation where evolution is possible
      • Understand existing code
  • Look in example
    • So what?
    • Try to understand in the real example
  • The Starting Point
  • Comments on the Starting Program
    • When you find you have to add a feature to a program, and the program's code is not structured in a convenient way to add the feature, first refactor the program to make it easy to add the feature, then add the feature.
  • The First Step in Refactoring
    • Before you start refactoring, check that you have a solid suite of tests. These tests must be self-checking.
  • Decomposing and Redistributing the Statement Method (Extract Method)
    • Refactoring changes the programs in small steps. If you make a mistake, it is easy to find the bug.
    • Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
  • Moving the Amount Calculation
    • Move Method
    • Replace Temp with Query
  • Extracting Frequent Renter Points
    • Extract Method
  • Removing Temps
    • Replace Temp with Query
  • Replacing the Conditional Logic on Price Code with Polymorphism
    • Moving methods to movie
  • At last … Inheritance
  •  
  • Thank-you for attending KhmerTech Feel free to join at http://groups.google.com/group/khmertech/