This post is part two of a series called Coding by the Book. Don’t miss its companion posts: How to Choose a Programming Book and The 7 Books Every Software Developer Should Read.
There have never been more ways to learn programming, from online tutorials to complete online courses to intensive programming boot camps. Tutorials are great but they often give you only the basics. Online—and offline—courses, meanwhile, can be very expensive and may tie to you their schedule. And while there are many ways to ask for peer help, you need to be far enough along the learning curve to understand the answers you get.
That’s why many people who want to learn coding—or just brush up on specific skills—still end up buying a book for help. It turns out that books can actually help you learn just about anything you need to know if you’re willing to put in the effort. Books also make great resources for later reference. To get started, try these helpful techniques to optimize the book-learning process developed based on feedback from the 96 computer and programming books I’ve written:
1. Read the whole thing
One common mistake is to not thoroughly read the explanatory material. Going directly to the coding examples without reading the accompanying explanation of how the code works is a recipe for failure. The reason you buy a computer book is to obtain the sample code along with the explanation that goes with it.
Computer books often contain extra information that you should highlight or mark up as you go along, such as reference material that would take you considerable time to research on your own. You can use the reference material as you code to discover other ways of doing things or other kinds of inputs to test as you work through the examples.
Of course, a single book can’t teach you everything about today’s complex coding environments. So, many computer books also cite carefully curated online resources that may hold the exact information you’re looking for.
2. Pay attention
Make sure you read only as long as you remain focused on the book. If you find yourself suddenly thinking about a fishing trip or the ball game on TV, it’s time to put the book down for a while. Casual reading simply isn’t good enough, you need to focus or there’s little point to the exercise. Don’t worry if you have to backtrack a little to ensure you actually understand the material that swam right out of your head as you were thinking of that fishing trip.
3. Download the code
Programming books usually come with downloadable source code. It’s important to download this source code, load it into the compiler, build it, and see what it does. These working examples are essential to understanding coding techniques. This source code ensures you see a working example free from problems like typos or other issues.
After you begin to understand the workings of the code, next you might want to try writing it out by hand to reinforce the principles you’ve learned. Typos are a major source of frustration for most novice programmers, so having the original downloaded sample code to reference for comparison makes it easier to find mistakes quickly and correct them. In addition to writing the code out by hand, practice typing it out as well.
4. Single step with the debugger
Depending on the language you want to learn and how much work the Integrated Development Environment (IDE) does for you, you may still not have a clear idea of precisely what happens when you run the application. The goal of many modern programming languages is to automate tasks, which is fine after you know how they work but is a potential obstacle to the learning process.
Single stepping through the examples helps you understand them in detail. As you step through, check the values of variables, verify how they change, and determine why they change in a specific way. Use the debugger features to change variable values so you can see how these changes affect the application. Look at the application memory to see how it stores information and check the call stack to determine precisely how a call is made. In short, explore every potential aspect of the application as you single step through it.
This approach also lets you explore other avenues of application development and design. For example, given the right circumstances, you can sometime enter file libraries to see how they work in relation to the application. In some cases, you can explore byte code or disassemble the application code to see how things function at a basic level.
Note: Single stepping with the debugger can cause the application to work oddly because some processes are time sensitive. In addition, you may need to restart the application at some point because the environment will become corrupted and you won’t get the results you might expect. The single-step approach works best with short code segments.
5. Play with the code to master it
At this point, you may think you have extracted every ounce of information that the book has to offer. However, you still haven’t played with sample code and tried to make it behave in different ways. Experimentation is a key to learning. Experimenting with the code examples in the book is a great way to build your skills. As you work through various extensions, you should start to understand how changes to the code affect applications as a whole. This sort of knowledge isn’t available any other way—you need to experiment in order to grasp precisely what the language provides in the way of functionality.
Eventually, you’ll begin creating applications that don’t look much like the book code at all. It’s at this stage, when you can begin building your own applications with confidence, that you really understand how they work.
Seven key milestones
Learning to code means understanding the language well enough to perform all the tasks required to build useful applications. This is the skill level that an employer will want you to have before hiring you for a developer job, for example.
The only way to acquire these skills is to learn all you can and to practice, practice, practice until you understand the process inside and out. When learning to code in a specific language, developers should strive to attain these seven milestones,
- Learn the language basics, such as data storage, keywords, decision making, and looping instructions.
- See the language used to perform specific tasks.
- Discover how libraries augment the language.
- Delve into the language details and build an understanding of how the language works at a lower level.
- Experiment with the language to see how interrelated changes affect each other.
- Use the techniques learned to begin building simple applications.
- Continue to build skills by creating progressively more complicated applications and researching additional language resources.
That may seem like a lot, but plenty of programmers can attest that you can actually reach all of these milestones with the help of a technical book … if you approach the process correctly.
Computer books and top image courtesy of Shutterstock.com.
The views expressed on this blog are those of the author and do not necessarily reflect the views of New Relic. Any solutions offered by the author are environment-specific and not part of the commercial solutions or support offered by New Relic. Please join us exclusively at the Explorers Hub (discuss.newrelic.com) for questions and support related to this blog post. This blog may contain links to content on third-party sites. By providing such links, New Relic does not adopt, guarantee, approve or endorse the information, views or products available on such sites.