Dive into other people's code
Being able to read other people's code is a force multiplier for becoming a stellar software developer.
When using open-source software, you'll undoubtedly need to examine code someone else wrote to better understand it.
Many times, you get to that point when you're debugging something. Your code does exactly what it should (of course!), but when it calls out to a 3rd-party library, something goes wrong. So you open that library in your editor and dig in.
On other occasions, documentation might not be good enough. Not to worry: you can open the code in your editor to see a method's full signature or all the possible configuration options.
Read more to speak better
Whatever the reason, you should embrace this possibility as it's one of the greatest ways to level up as a programmer.
You can be intentional about it and crack open the source code of some of the more popular libraries, as they tend to be well-written. If you peruse excellent code, you will learn to write better code in that language and in general.
There is a parallel here with natural languages. If you read books from excellent writers, you'll speak a more varied, pleasant language with a more extensive vocabulary and also write better.
Occasionally, you can even improve the library. Maybe you see a code comment that's no longer relevant or downright misleading – or perhaps you want to add a comment yourself. Or, you want to refactor some code to be more descriptive or flexible. Leveling up, you might want to add a feature to make a particular use case possible.
If you do any of these, you'll grow even more as you'll understand someone else's code so well that you can extend or modify it.
When browsing "foreign" code, there will be many things you have no idea about the first few times. Don't despair – you'll gradually understand more and more over time.
Peeking inside
Opening a library's code in your editor is similar to taking apart a mechanic toy or an electronic device. I never had the curiosity (or the courage —what if I can't put it back together?) to pick real things apart to see how they work, but I know many people do.
Having read several libraries and apps, I can now totally relate.
There's something magical about delving into the code of a new project for the first time: you wonder how it works, and as you take in more and more of it, you make the connections inside your brain and build up your mental model.
In some cases, you'll be in awe of the fantastic work smart library authors (who don't write smart code) did. In others, you'll instinctively think about how you could improve it.
In either case, you'll grow as a developer.
Your day-to-day
So far, I've only discussed open-source software and the importance of reading, understanding, and possibly modifying code others wrote when using OS libraries.
But wait. Is there something similar all software developers need to do even if we don't do OSS?
There certainly is, as that's precisely what you have to do every day. In the projects at your company, most of the code has been written by your co-workers, current and long gone. You wrote some of it, but you know the trope: you might not even realize the code you wrote a few months earlier, so you might consider yourself someone else in this context.
In summary, you should read other people's code for the following reasons:
- You'll learn new ideas and patterns in that language and extend your coding arsenal. You'll vastly improve your knowledge of the language, much more than by watching hours of videos or reading dozens of articles.
- The magical mind exercise of gradually understanding how a complex piece of code is structured and how the pieces make a working whole
- Reading code you didn't write is a huge part of what you do at your day job, so you'll become better at that, too.