Reading Someone else’s code
“But HOW???, WHY?? … why won’t you just do that instead? “
A junior web developer who just got his ( her’s ) first job in the real world, is going to have the most confused look on their face for a long time. The product is more complexed than it looks, the code is a mixture of legacy code and cutting edge technologies in which Stackoverflow doesn’t have all the answers yet, and the bosses are expecting way to much. Overwhelmed is an understatement. So what can a junior developer do to help himself (herself)?
Looking for patterns — developers have habits. some bad and some good but its still a pattern. for example:
<html><div class= ‘clickAbleDiv’>click me </div><div onclick=’clickFunction()’>click me2 </div></html><script>document.getQuerySelector(‘. clickAbleDiv’).addEventListener(‘click’, clickFunction)function clickFunction() {console.log(‘clicked’);}</script>
Located above are two simple examples of a click function. assuming that this code is understandable to all of you and if not, please go study that first.
These two options are here to show an example of different coding patterns. some like to mix the logic of javascript within the html file (on click attribute) and some prefer to keep the two apart. (addEventListener). Figuring out this pattern will help the first steps of how to begin a new task given for the first couple of times. for example: If you know that The senior developer likes to keep the logic and structure in different files that you know you need to look in the html for a unique identifier and use it to search the js file to figure out what is being done with said element. Even if you don’t know what to do, at least you know where to do it …. right ?
Most developers are usually not aware of their quirks and patterns and asking for or about them will not lead to beneficial answers, if not an angry snark.
Creating point breaks in code — Seeing a lonely function or module without understanding why it’s there, can be frustrating and borderline crazy.
If you are using jet-brain’s IDE or any other true IDE you can force debugging/ point breaks in the code. doing so will give you a slow down or a pause of all those functions and data which are processing so darn quickly , its hard to keep up with it. Seeing real time data, instead of variable names , and how the data is manipulated , will give you better information and a higher understanding of how the code works and how the data flows in the app/website/mobile/server/ you get the point.
Refactoring — The need to add functionality or change a function is a common occurrence. as a junior , this may be all you do. editing and adding to existing code. for you to improve and do it well there must be a good understanding of the code, but wait…. but why… ( the cycle continues). By rewriting, even if just for your self, writing the code will first of all teach you to write real time production level code (correct error handing, efficient queries etc.. ) and also give an in-depth knowledge about what the code does and why.
Being a junior is hard , very, especially when you don’t know how to read the code, how to dismantle it into the the small components(see what i did there) that make sense and how to add to those small pieces that will compile into a large complexed app after that first pull request will be accepted.
GOOD LUCK !