Today I will be focusing on the Apprenticeship Pattern “Use the Source”. This pattern talks about reading other people’s code to learn by their example of how to do things, so that you have a solid foundation of where to go when you actually start writing the code. As if your code disagrees with your intentions, it will never work.
The pattern also talks about how the “Practice, Practice, Practice” pattern will only reinforce bad habits if you do not know any good ones to practice by. This is important as habits can be hard to break, so it is best to start with good habits rather than bad ones that you may need to break later on.
A good idea is to start by reading code for applications and tools that you use every day and learn by their example. This helps you learn how the other programmers code, and helps you understand the thought processes that create the infrastructure of the programs and tools that you use. Another good idea is to download open source projects, downloading them from the current version of the source code, using source control, to learn the history of how it has changed and so you can learn how future changes are affecting it.
You can then also try to refactor the codebases to try to understand why the programmers made the choices that they did, and also any consequences there might have been if you were the one writing the program instead. This helps you further understand the projects, and it also helps you to build the projects as well.
However, during your exploring you will eventually come across some decisions you may disagree with. It is important to ask yourself if the developers knew something you did not, or vice versa. It is good to realize that maybe there were things outside of the developers control that required them to make those kinds of decisions.