This post is first posted on my WeChat public account: GeekArtT

Reading source code is always one big part for software engineers. Just like the writers to learn writing by reading a heck of classic books, like the painters to “read” a bunches of pictures, software engineers will learn a lot from other one’s work. Source code is like the art museum for artist. It’s the technique library for all they need to build and create. Although it’s easy to know the importance of reading source code, it’s really hard at beginning to get used to that kind of technique reading. At least I did pay lots of pain on the initial stage.

The direct questions that a newbie may ask when they meet such giant work are:

  • There’s too much source code, where should I start?

  • As there’s millions of lines of code, how is it possible to go through every part of them?

  • After read a groups of small modules, I just still don’t know why it should exist? Why are they interesting?

  • After a period of time, I still can’t see what the value is from reading source code.

For any person, when they first meet a task with so large number of materials, they’d get dizzy. It’s not only happening in reading source code, it may also happen in any other fields like reading books, writing books, building a website, building a bridge across a river, etc. It’s the typical character of large project.

For any large project, the first headache is solving the problem of large amount. Luckily, in the history of human beings, there’s one field to deal with this kind of problem named engineering. The kernel thinking of engineering is how to manage the complexity. And one of the powerful weapons is decomposing your task. Deal with large problem is tremendous horrible. You need to divide it into small manageable parts to make things easier and system. At least for the concern of psychology, just name clearly the detailed steps you need to overcome to get things done can make yourself feel better. So does read source code. You need to decompose the source code you’re trying to research.

But how to divide it? What rules should you obey to make the divided parts more efficient for you? That’s the second aspect of our discussion, where you should start.

In my opinion, the key point of knowing how to start or decompose your task is trying to understand your project, and get the project’s domain knowledge as much as possible. At the initial stage, you should plan to understand the project that you’re reading clearly. You need to know what the purpose of this project is, what kind of specific problem it dedicates to solve, and what performance standard you can use to judge the excellence of this project. Then, you need to know this project’s domain knowledge, what the problem this domain cares, what kind of thinking way this domain constructs, and how this domain runs.

Why do we need to know these? Because once you’re in the details sea of source code, you may totally lose yourself without any direction. You may not feel the cherish value, high quality of the code snippet you’re reading unless you fully understand what the original problem is, how hard it is, and how valuable if someone can solve this problem. Once you know the meaning of your reading code, the mission of your reading commitment, you’d be motivated hugely with great passion. Your whole reading journey will become funny.

The domain knowledge is not only important for code reading, it also matters about your career. If you don’t know the domain you’re working on, if you don’t accept the value or mission of your task, it’s really hard to make your career successful. You may get confused about the key point of this field. You don’t know how to improve this field in practical way. Your efforts paying may push your career on reverse direction, and get the disdain from community. You’d feel really hard to catch up the trend, and do lots of invalid work due to the lack of domain knowledge. It’s really frustration. So, no matter if you’re reading source code or choose your career, pick up the field, community that you do really trust and believe.

From this viewpoint, the project that you may probably mess up is the one you’re unfamiliar with and without any interest. Doing domain research is not an easy work, especially when you’re not familiar with the domain of programming itself. It’s really tough to do two complex unknown tasks at the same time. So my suggestion is reading the project source code that solves problem in your daily life, or problem you’re really caring and very interested in.

After talking about those motivation stuff, we need to handle the technique parts. As a newbie, it may also be hard to catch the value even after a long period of reading source code. For this part, it often relates the bad way to deal with your reading.

The first issue you need to handle is you must know how to distinguish what the difference is between good code and bad code. The standard determines good or bad is based on how easy you can modify or do something for your code. As you getting more practice, you’d accumulate more experience about failures and frustration. Then, it’s much easier for you to understand convenience. In one period, I’d just get frustration that why the programming is so hard and boring to deal with lots of details. I’m not the machine, how I can handle so huge amount of special cases, and keep adding something from scratch. I got the real problem from my practice, but I did propose a wrong direction question. The frustration I met is not due to the complexity of task. It’s due to the way to handle this task. And that introduce the concept of your code design. Good code is always designed well to make your management on complex task easy. Control the complexity is always the meat of engineering!

According to this perspective, you can know how you read the source code. When you start your reading, the first step is of course figuring out what it executes. But that’s only the prelude. The more important focus you should put on is the design of your reading snippet. What is it constituted? How those part can make the problem easy to be solved? Why this line should exist? Is it due to the concern of macro scope or micro?

Another technique issue you need to address is how low level you should understand about your code. I think you need to dig into your code as low as the machine level, or assembly level. The process of reading source code is very much like reading mathematical proof. The detail always matter. You need to decompose the complex solutions into the atoms. For math, the atom is definition or axiom; for computer science, the atom is the machine level language. Computer is nothing but movement made by machine. It’s just a lot of physical operations, no magic. But if your understanding of any programming operations can’t be connected to machine movement, you’d always be stumble by some black box or black magic. Image the programming’s operation as magic is the sign of your poor understanding, which means you can handle the computer as you want. Probably, you’re handled by computer, or fooled by your own poor understanding. Once you make black box for yourself, you’d never feel you’re qualified on this work.

Reading is always the superficial behavior of getting benefits, but that’s not. The real core part is the thinking that introduced by your reading. So, play more on your practice journey with reading, and think harder.

If you do like my posts, please subscribe my WeChat public account by long pressing below QR code.

Tips for newbie to read source code的更多相关文章

  1. 编程等宽字体Source Code Pro(转)

    Source Code Pro - 最佳的免费编程字体之一!来自 Adobe 公司的开源等宽字体下载     每一位程序员都有一套自己喜爱的代码编辑器与编程字体,譬如我们之前就推荐过一款"神 ...

  2. How to build the Robotics Library from source code on Windows

    The Robotics Library is an open source C++ library for robot kinematics, motion planning and control ...

  3. How to build windows azure PowerShell Source Code

    Download any version source code of Windows Azure Powershell from https://github.com/Azure/azure-sdk ...

  4. akka cluster sharding source code 学习 (1/5) 替身模式

    为了使一个项目支持集群,自己学习使用了 akka cluster 并在项目中实施了,从此,生活就变得有些痛苦.再配上 apache 做反向代理和负载均衡,debug 起来不要太酸爽.直到现在,我还对 ...

  5. view class source code with JAD plugin in Eclipse

    The default class viewer doesn't decompile the class file so you cannot open and check the source co ...

  6. Classic Source Code Collected

    收藏一些经典的源码,持续更新!!! 1.深度学习框架(Deep Learning Framework). A:Caffe (Convolutional Architecture for Fast Fe ...

  7. Attach source code to a Netbeans Library Wrapper Module

    http://rubenlaguna.com/wp/2008/02/22/attach-source-code-to-a-netbeans-library-wrapper-module/ Attach ...

  8. convert source code files to pdf format in python

    import os import sys def find_file(root_dir, type): dirs_pool = [root_dir] dest_pool = [] def scan_d ...

  9. Ununtu 12.04 gedit安装插件Source Code Browser

    1. 安装ctags: sudo apt-get install exuberant-ctags 2. 打开https://github.com/Quixotix/gedit-source-code- ...

随机推荐

  1. 关闭rdlc报表打印预览后,关闭客户端,抛出异常“发生了应用程序级的异常 将退出”

    问题:关闭rdlc报表打印预览后,关闭客户端,抛出异常“发生了应用程序级的异常 将退出” 办法:在容纳ReportViewer的窗体后台代码中,添加如下代码即可 protected override ...

  2. MacOS下Express安装过程中遇到的问题

    问题描述: 使用nmp install express -g命令全局安装express后,在终端使用express -V命令可以获取到express的版本号,但在引用express的项目运行时,会报缺 ...

  3. 创建WP8试用应用

    参考资料: 创建 Windows Phone 的试用应用 如何在 Windows Phone 应用中实现试用体验 Windows Phone 7 开发 31 日谈——第23日:提供试用版应用程序 对资 ...

  4. jquery+bootstrap实现tab切换, 每次切换时都请求数据, 点击提交分别向不同的地址提交数据

    今天一个朋友叫帮做一个tab切换, 每一个tab内容区域都是从后台取出的数据, 这些数据要用表格的形式显示处理, 并且表格的内容区域可以修改, 如下所示: 例子查看请演示查看. 截图如图所示: 实现步 ...

  5. 9_bootstrap less 移动端

    chrome,firefox提供了"Device Emulation"功能,可模拟常见的各种浏览设备 android ADT或ios Xcode附带的设备模拟器,或第三方在线测试工 ...

  6. iOS判断对象相等 重写isEqual、isEqualToClass、hash

    相等的概念是探究哲学和数学的核心,并且对道德.公正和公共政策的问题有着深远的影响. 从一个经验主义者的角度来看,两个物体不能依据一些观测标准中分辨出来,它们就是相等的.在人文方面,平等主义者认为相等意 ...

  7. Flume_常见的几个问题

    在HDFS的文件默认生成文件大小1K,如何设置文件大小和数量 拷贝一份flume-conf.properties.template改名为hive-mem-size.properties hive-me ...

  8. hadoop生态圈介绍

    原文地址:大数据技术Hadoop入门理论系列之一----hadoop生态圈介绍   1. hadoop 生态概况 Hadoop是一个由Apache基金会所开发的分布式系统基础架构. 用户可以在不了解分 ...

  9. 一眼看懂深浅拷贝(clone)-C#

    这是使用的是序列化的方式实现深拷贝 [Serializable] class Person:ICloneable { /// <summary> /// 字符串在clone 中类似于值类型 ...

  10. linux命令初识

    一.查看当前的目录文件 ls  demo   查看demo目录下的所有文件 ls  -l  demo/test.txt   --查看指定目录(test.txt)的详细内容 二.复制文件 cp   or ...