Becoming an excellent developer takes a lot of time and effort. In the first tutorial in this series, you've learned the fundamental rule to keep exploring. Only if you continue to delve into new code, problems, and challenges you'll grow as a software developer.
In this tutorial, you'll gain knowledge of an essential way to do it: reading lots of code.
How to Become a Better Developer #1 Series Overview
Read Great Open Source Code
While writing code hones your skills to create new software, it doesn't necessarily teach you how to create it well. There are numerous patterns and architectures to learn, which also can depend on the field. For example, the way to structure an Android mobile app is quite a bit different to a hapi web app.
In the first tutorial, we recommended the head first design patterns, because you'll learn new patterns in a playful way. But how to apply these patterns in the real world is still another step you'll have to take. The best way to see common patterns in your field in action is to dig into open source code.
Open source code is great for many reasons, but in this context, it provides you with a free and interactive learning platform. Open source projects that are popular are often (not always) good indicators on how to write code well. For example, if you're a hapi developer, you may want to look at Marcus' hapi plugin "hapi-dev-errors". If you're an Android developer, you may want to look at Jake Wharton's u2020 app. If you're a developer in a different area, look for a high-quality project.
Once you've found a nice project, dig into it. This is important, really dig into it. Don't just browse through the code and think to yourself: "this is nice", but consciously think about their design choices. What kind of architecture does the project use? Why did they go with the XYZ pattern here? What kind of tests are they running? This is a critical step as you look for something you don't know (well) yet. But seeing in action will give you a chance to understand it much better, which is a fantastic, direct learning opportunity.
While you keep digging into the project, resist the urge to devalue anything that you're not used to. If you encounter something that you would have done different, try not to skip over it. There most likely was a conscious decision to go with this solution and not what you would have done. Take a minute and think about it. You could look into the issues and code history to see if someone else had that thought, and if not and you are convinced your solution is superior, you could open an issue and nicely ask the maintainer.
Read Bad Code
This brings us to a serious point: not all open source code is automatically great. In fact, there is a lot of bad code out there. For example, the Android app of Telegram with millions of users is objectively terrible in many, many ways. This means you should not just hastily copy any code you see in open source projects. That's why it's so important to consider the reasons behind a certain design decision. This is a tough challenge. It's not easy, especially during the first years, to recognize what is good code and what is bad code.
One way to get better at recognizing bad code is to particularly study bad code, or anti patterns. Anti patterns are demonstrations on how not to do it, because they're objectively a bad solution. Wikipedia provides a decent list of anti patterns with links to more in-depth articles. Definitely worth a read!
In this tutorial, we've discussed how important it is to read lots and lots of code. It's particularly critical that you make this a conscious effort. Try to understand why something was build this way and whether that is a good or bad idea.
Congratulations, you've just leveled up your programming skills 1 🎉
Do you have further questions or suggestions on this topic? Let us know on Twitter @futurestud_io or leave a comment below.
Enjoy coding & make it rock!
1 Well, after reading a bunch of open source code, just reading this tutorial unfortunately is not enough.