Skip to content

Instantly share code, notes, and snippets.

@parkerl
Last active August 29, 2015 14:01
Show Gist options
  • Save parkerl/f7c331eb989956165e43 to your computer and use it in GitHub Desktop.
Save parkerl/f7c331eb989956165e43 to your computer and use it in GitHub Desktop.
Working Effectively with Legacy Code: Chapters 14 to 17

###Chapter 14: Dependencies on Libraries Are Killing Me###

  • Avoid promiscuously calling on libraries throughout your code. (ActiveRecord??)
  • “Every hard-coded use of a library class is a place where you could have had a seam.”
  • Is there any relevance for the language feature enforced design constraints in Ruby? Objective-C?

###Chapter 15: My Application Is All API Calls###

  • Don't test if your app is all API calls?
  • ActiveRecord must be one the best tested libraries in existence
    • We often test validations, associations, etc.
    • The above ususually have "special" options but are still straight AR calls.
  • Sorting out a mess:
    • “The first step is to identify the computational core of code: What is this chunk of code really doing for us?”
    • There are essentially two approaches:
      1. Skin and Wrap the API
      2. Responsibility-Based Extraction
    • Skin and Wrap
      • Create a wrapper to be used in place of the API
      • Make an interface to closely match the API
      • Good when
        • The API is relatively small.
        • You want to completely separate out dependencies on a third-party library.
        • You don’t have tests, and you can’t write them because you can’t test through the API.
    • Responsibility-Based Extraction
      • The API is more complicated.
      • You have a tool that provides a safe extract method support or you feel confident that you can do the extractions safely by hand.

###Chapter 16: I Don’t Understand the Code Well Enough to Change It###

  • Notes/Sketching
  • Printing out the code
    • Seperating responsibilites
    • Undertand method structure
      • Line up the blocks
    • Extract methods
    • Understand the effects of change
  • Scratch refactoring
  • Deleting un-used code

###Chapter 17: My Application Has No Structure###

  • Telling the story
    • “What is the architecture of the system?”
  • Naked CRC
    • “Class, Responsibility, and Collaborations”
  • Conversation Scrutiny
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment