Break it Down

Breaking a puzzle into pieces
Image by Hans from Pixabay

Last time we discussed committing to a single unit of practice whatever that unit is. One of the big reasons for doing that is to maximize the learning at each step. Let’s dig into how we can maximize the learning for a given unit.

When golfers get their swing analyzed, it will be recorded at high speed so that it can be played back in slow motion. That way every nuance of stance, arm movement, angles, head movement, etc. Every part is dissected in detail and refined to maximize the power and accuracy of the swing. Then all those refinements are added, one at a time until each is mastered and natural, until the swing is optimal. Even Tiger Woods, one of the greatest golfers of all time, went back and refined his swing when he wanted to improve his game.

Just as the great sports masters break their movements down into smaller steps to refine each, you can do the same with your practice sessions. Let’s say you want to master a refactoring technique. One great way to do this is to get Martin Fowler’s detailed description of the necessary steps to execute it from his book. Since he has example code and the specific steps to take to execute the refactoring, he has it broken down into steps for you. So, to practice, after you have worked through his steps on his sample code a few times, you’ll understand it well enough to try it on some other code. You can get the Refactoring Workbook for some additional specific examples. There are also refactoring katas for specific refactoring techniques you can use to try this. Once you are comfortable exercising the technique on familiar code, it’s time to find where you might apply it on less familiar code. Find an open-source project or some code from your work where you might apply it and try to implement it there.  It’s critical to continue to practice this one refactoring until it becomes natural to recognize where it can be used, and natural to implement.

The important thing is to keep the steps small and master each one:

  1. Know how to recognize code where the refactoring technique can be used
  2. Know the steps to perform the refactoring
  3. Know each step, and the transitions from the previous to the next step
  4. Know why skipping steps will sometimes lead to confusion
  5. Know what the refactored code should look like when properly performed

You can come up with similar steps for anything you want to master. If you want to remember useful shortcuts for your IDE, you can create a set of code where you can practice that keystroke over and over until it is natural. If you want to master reading code, you can have a resource for finding unfamiliar code to read and a system to verify that you really understand it.

One step at a time. Maximize your learning at each step until it becomes second nature. This leads to mastery!