Refactoring, A First Example

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Notes on slide 1

    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.

    Favorites, Groups & Events

    Refactoring, A First Example - Presentation Transcript

    1. Refactoring, a First Example Vorleak Chy (vorleak.chy@gmail.com) Software Engineer Yoolk Inc http://groups.google.com/group/khmertech/
    2. Before Refactoring
      • Unreadable code
      • Duplicated code
      • Complex code
      • Hard to modify
    3. After Refactoring
      • Easier to understand
      • Cheaper to modify
      • Clean code
      • Better code
    4. Introduction
      • What is Refactoring?
      • Why Refactor?
    5. 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.
    6. 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
    7. 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
    8. Look in example
      • So what?
      • Try to understand in the real example
    9. The Starting Point
    10. 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.
    11. The First Step in Refactoring
      • Before you start refactoring, check that you have a solid suite of tests. These tests must be self-checking.
    12. 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.
    13. Moving the Amount Calculation
      • Move Method
      • Replace Temp with Query
    14. Extracting Frequent Renter Points
      • Extract Method
    15. Removing Temps
      • Replace Temp with Query
    16. Replacing the Conditional Logic on Price Code with Polymorphism
      • Moving methods to movie
    17. At last … Inheritance
    18.  
    19. Thank-you for attending KhmerTech Feel free to join at http://groups.google.com/group/khmertech/
    SlideShare Zeitgeist 2009

    + Vorleak ChyVorleak Chy Nominate

    custom

    101 views, 0 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 101
      • 101 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 6
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories