Episode 57: Refactoring Code

Play

Refactoring your code is essential in large topics. We talk about what refactoring is and things to look for when refactoring

News/Follow-ups – 00:36

Geek Tool – 06:40

Webapps – 09:09

Topic – 15:56

  • Refactoring Code
    • What?
      • Change source code without changing the external functions/behavior
    • Why?
      • Improved readability
      • Reduced complexity
      • Improved maintainability
      • Improve extensibility
    • Things you can do
      • Break large routines into smaller sub routines
      • Look for duplicated code and reduce it to used a shared function
      • Code smells (episode 21)
      • Find old commented out code and remove it, use SCM for storing old code you might want
      • Find methods with 7+ parameters – Usually means that a new class should be created
      • Replace variables with names like x and foo – Sometimes as developers we are too busy in our train of thought to think of descriptive variable names and make something up just for the time being.  Find these and change them to more descriptive ones.
      • Look for comments that tell the what and not the why
      • A severe code stench emanates when the scroll bar appears – Reduce complex  nested ifs and loops
      • Look for methods for gtgtwhich you cannot understand/explain in less than 25 seconds
    • A group of unit tests are needed before refactoring
    • Getting Started with Refactoring

2 Responses to “Episode 57: Refactoring Code”

  • Brian Says:

    Pretty cool seeing the sorting algorithms visually. I had a Computer Science professor who was really into sorting and made code all of the popular sorts.

  • Jade Robbins Says:

    Yeah looking at those animations reminded me that I don’t remember how to do the different sorts anymore! I should bone up.

Leave a Reply