Your SlideShare is downloading. ×
0
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Refactoring
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Refactoring

1,270

Published on

This is my presentation in Tabriz open space meeting about Refactoring.

This is my presentation in Tabriz open space meeting about Refactoring.

Published in: Education, Technology, Design
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,270
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
80
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Clean Code
    Refactoring
    1
  • 2. Refactoring
    Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
    2
  • 3. Refactoring
    What is Refactoring?
    Martin Fowler : "a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior“.
    William C. Wake : "Refactoring is the art of safely improving the design of existing code“.
    3
  • 4. Refactoring
    The process of refactoring involves the removal of duplication, the simplification of complex logic, and the clarification of unclear code.
    The goal of refactoring is NOT to add new functionality
    The goal is refactoring is to make code easier to maintain in the future
    4
  • 5. Refactoring
    When Should You Refactor?
    • Refactor When You Add Function
    • 6. Refactor When You Need to Fix a Bug
    • 7. Refactor As You Do a Code Review
    5
  • 8. Refactoring
    The Refactoring Cycle
    Choose the worst smell
    Select a refactoring that will address the smell
    Apply the refactoring
    6
  • 9. Refactoring
    Bad Smells in Code
    7
  • 25. Refactoring
    Bad Smells in Code
    • Inappropriate Intimacy
    • 26. Alternative Classes with Different Interfaces
    • 27. Incomplete Library Class
    • 28. Data Class
    • 29. Refused Bequest
    • 30. Comments
    8
  • 31. void printOwing() { printBanner(); //print details System.out.println ("name: " + _name); System.out.println ("amount " + getOutstanding()); }
    Refactoring
    Extract Method
    void printOwing() {
    printBanner();
    //print details
    System.out.println ("name: " + _name); System.out.println ("amount " + getOutstanding());
    }
    Reusability
    High Cohesion
    Readability
    void printOwing() {
    printBanner();
    printDetails(getOutstanding());
    }
    Void printDetails (double outstanding) {
    System.out.println ("name: " + _name);
    System.out.println ("amount " + outstanding);
    }
    Polymorphism
    9
  • 32. Refactoring
    Move Method
    10
  • 33. Refactoring
    Move Method
    low Coupling
    High Cohesion
    11
  • 34. Refactoring
    Encapsulate Field
    you should never make your data public. When you make data public, other objects can change and access data values without the owning object's knowing about it.
    12
  • 35. Refactoring
    Extract Interface
    13
  • 36. Refactoring
    Remove Parameter
    A parameter is no longer used by the method body. Remove it.
    14
  • 37. Refactoring
    Replace Nested Conditional with Guard Clauses
    A method has conditional behavior that does not make clear the normal path of execution.
    Use guard clauses for all the special cases.
    Readability
    15
  • 38. Refactoring
    Visit our Page on Facebook!
    16

×