"The more that you read, the more things you will know. The more that you learn, the more places you’ll go." —Dr. Seuss
- Apply reading process to interpret unfamiliar code
- Identify input/output flow of a method
- Separate actions within an existing method
- Distinguish clear and opaque code
- Identify where to start
- Identify inputs and outputs
- Distinguish and separate which parts of the code are clear and which are opaque
- From your starting point, walk through the code linearly until your reach opaque code.
- Repeat steps 2-4 on the opaque code
- Continue through all opaque code until the end
In this lab, we're going to apply the process discussed in the previous lesson for interpreting unfamiliar code. The code in this lab is written already, but unfinished. Don't worry about finishing the code - your first task is interpret what is already there - to build a model of how it works in your mind so that you may answer some questions about it.
Once you become more familiar with the code, provide the correct return values
for the methods in answers.rb
. Run learn
to check your answers.
All programmers face the challenge of using code they don't understand. It doesn't make sense to invent the wheel every time a car manufacturer wants to build a car. Nor anti-lock brakes, airbags, seatbelts, etc... The modern car manufacturer gets many parts pre-made somewhere else, and only worries about the assembly. We don't always need to code every part of an application, and often rely on gems or other existing code to handle specific tasks. Sometimes its better for critical components of an application to use existing code that is well-tested.
If, however, we want to have the ability to change and contribute to a codebase, we need to be able to develop an understanding of it.
Now that you have a grasp of what the code does, can you imagine extending it? What games could you build using this code?