Usually when I learn new things, like a programming language or a new automation tool, I like to take a complete course. Courses are structured for logical, incremental learning. But sometimes when I want to learn something quickly, I use what I call “The Ripping-Out-Code Method”. I don’t know if anyone else uses this method, but I’d like to think that my name for it is original!

The Ripping-Out-Code Method involves taking a code project written by someone else and working to understand it by gradually removing lines of code until you are left with the basics. Here’s how it works:
Step 1: Find some code you want to understand
This could be some test automation code in a new framework, some production code that you will be testing soon, or some kind of script that you’d like to use.
Step 2: Pull down the code
Pull down the code from the repository where it is located.
Step 3: Save a copy of the code
When using the Ripping-Out-Code Method, you might occasionally find that you’ve ripped out too much code, and then can’t remember how to put it all back again! If this happens, it’s nice to have a fresh copy of the code to switch to so you can start over.
Step 4: Read through the code
Before you make any changes at all, take a look at the code to see if you can figure out what’s going on. See whether you can locate functions that are being called, whether you can find the values of variables that are being used, and so on.
Step 5: Run the code
Once you have a sense of what the code is doing, it’s time to run the code. Watch what happens when the code runs, either through the log statements or through the UI. If the code consists of automated tests, watch the tests run and pass.
Step 6: Make a small change to the code
Now that you have confirmed that the code is working, make a very small change. For example, if there is an automated test that enters a value, change the value and run the code again.
Step 7: Start removing lines of code
At this point, you should probably have a rough idea of how the code works. Now it’s time to start ripping out the code! Look for things you don’t need. For example, maybe the code contains some UI tests, and you’d just like to focus on API tests. Start ripping out the UI tests. Don’t rip out too much, though! Make a note of what you are doing, perhaps even copying the code into a separate document, so that you can put the code back in if you need to.
Step 8: Run the code again
Once you’ve ripped out some lines of code, run the code again to make sure it still works. If the code doesn’t work any more, you know you’ve ripped out too much! Add the removed code back in, and take a look at the code to determine why it was needed. However, if the code does work, it’s time to rip out more code.
Step 9: Repeat steps 7 and 8 until you have removed as much code as you can
In the example above, where you wanted to focus only on API tests, you might look through the code to find classes called by the UI tests but not the API tests. Rip out those classes one at a time, running the API tests each time to make sure they still pass.
Step 10: Use what you’ve learned to write some new code
Once you’ve ripped out as much code as you can, you should be left with the basics of what you need. Moreover, you should have a pretty good idea of why the leftover code is still needed. Using this knowledge, try creating a new project and writing the code on your own.
The Ripping-Out-Code Method does not work for everything. If you are learning a new programming language, for example, it’s probably best to start with a beginner’s course. But if you already know a bit about the code or tool you are working with, this method can be a quick way to learn. If you try it out and find success with it, please let me know in the comments!