7 Ways to Improve Your Code Reading Skills

 

Abstract: As more and more companies use agile development, being able to read other people's code is more important than ever. This requires learning some tips on how to improve this skill. This article provides 7 ways to improve your code reading skills, the following is the translation. Read the source code in the software developer job description. However, the experience is not always pleasant. Not everyone enjoys reading other people's code because they find it tedious and sometimes frustrating. There are cases where you start reading someone else's code and you end up feeling a pain because you can't understand the code, or the code is poorly written. Most developers want to focus on writing code rather than reading code, and they don't realize that reading code is also an important skill. It can be said that there are many benefits to reading the source code. The benefits of reading the code are huge. Coding can be compared to literature. Most writers focus on reading classics as they write. The reason is that you can't create anything in a vacuum (closed doors). You have to draw from different sources and work on them to create your own masterpiece. The same goes for writing code. To be able to write good code, you have to read a lot of good code. In this way, you can see how other developers think and solve specific problems, as well as discover where they fall short. You can gain different ideas, styles, and patterns from reading other people's code, allowing you to gradually grow your knowledge. In one word -  code reading skills improve coding skills. There are many ways to improve your reading skills. In this article, I would like to mention a few points. 1. Running the code - yes, this is the first step in reading the code. This probably won't give you too much detail about the project, however, you will know how to build it and run it, you will learn about the libraries it uses, the development frameworks it depends on, and so on, which is a great way to improve your understanding of a particular Good way to understand the project. If you want to write your own software similar to the specific project you're exploring, you might have some ideas about which framework or library you should use. 2. Find high-level logic 






 





- When you start reading the code of a project, you may get bogged down in every detail. This is problematic, instead you should focus on high-level structures. To find the entry point and go from there, most software projects have a main way to go from there. Also, if this is a web app, start looking at the different packages like where the business logic lives, where the UI code lives, where does the controller go, etc. Basically, just go through the whole project and get a basic idea, then ask yourself where you want to focus and start with that section. You don't have to read the full codebase, but just the parts of it that might interest you. When you find your entry point, you can call the method and see where it leads you to understand the business logic of the project. 

3. Use/Understand Tools - There are many tools that can be used to read and explore the source code, which can help to visualize the code. For example, the IntelliJIdea tool has the ability to navigate source code, allowing you to search by words, parts of words, and even abbreviations of words. You should also learn keyboard shortcuts. Navigating source code with a mouse can be rather tedious and slow, using keyboard shortcuts makes jumping faster. You can quickly jump from one part of the source code to another. 

There is also a good software for reading code called Sourcegraph, which was created by two Stanford grads, Quinn Slack and Beyang Liu, who after spending time looking at undocumented code decided to develop a tool to help them better read and understand the code. 

4. Know the language/conventions - A deep understanding of a particular language can help improve code reading skills. Each language has its own set of conventions, styles, and syntax. This knowledge helps you quickly become familiar with a particular code. For example, in the java language, the method name starts with a lowercase letter, while in the C# language, the method name starts with an uppercase letter. Knowing this difference can help you identify methods from source code. 

5. Read Best Practices/Design Patterns- It's only natural that the code you're reading, or one of its structures, may seem obscure, or you may not be familiar with it. There are many good practices and design patterns that people use to do things correctly and optimally. For example, there is a pattern called Singleton whose constructor is kept private. You might ask, why on earth would anyone want to keep a constructor private. I always thought it was public, otherwise, how would I create an instance of a class. Well, there is a reason behind this. The Singleton pattern prevents you from instantiating a class more than once, which has many practical use cases. If you understand the pattern, you won't be banging your head against the south wall for it. So, knowledge of some patterns, for example, Gang of Four (Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, four of the world's top masters in software design.) There are 23 documented design patterns that can be significantly Help you improve your code reading ability. 

6. Code Review - Software development is a very collaborative job. No one can build a large or important piece of software alone. Every software is built by a team. In a team, everyone contributes their part to shape the project. On the day the project ends, everyone's contributions are merged into a work that is truly valuable to the user. In addition to doing the actual coding, each team now has another practice of reviewing each other's code while observing, advising, and learning from each other. It's a powerful tool for building codebase knowledge, creating strong bonds within the team, improving code quality, reducing bugs in the system, and keeping customers happy. 

To do code review, you have to read other people's code on the team, which will eventually improve your code reading ability. 

7. Temporary refactoring - Temporary refactoring can also help you improve your code reading skills. You can take a long piece of method code and continually subdivide the method into parts. Keep decomposing until you understand the real meaning behind this chunk of method code. Afterwards, you can annotate these methods and roll back those changes. 

This can help you understand the structure of the method and can also increase your knowledge of code refactoring.

 

 

http://www.iteye.com/news/32711

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326353484&siteId=291194637