W08 - How to Write Good Code

Last week our team discussed how to write good code; here I offer some extended reflections.I want to share a general rule: continually improve the quality of your information sources. Writing good code is also a process of learning plus practice, and seeking high-quality sources is a strong motivator for growth.

When I first started working, I often read public blog accounts. Opening an article would often make me think, “Wow, this is great, this is exactly right—better save it.” Over time I found that some developer communities produced more systematic content, much of it originating abroad, such as media and Google Developer. For a while I even enjoyed doing translation work. Later I followed some book lists and listened to senior practitioners strongly recommend classic titles. After reading a few, I realized that much of what I’d previously read were fragments—excerpts, amplifications, or practical takes on certain chapters of those books. Such books aren’t usually new and are often reissued many times, but they stay fresh on repeated reading—examples include The Pragmatic Programmer, Refactoring, The Design of Everyday Things, and works by Yukihiro Matsumoto.

My personal experience felt like piecing together a puzzle at first: collecting fragments, self-exploring, forming theories, only to discover I was often reinventing the wheel. Later it felt more like planting a tree: build your own knowledge-structure trunk first, then hang fragments on it. The advantage is that once you can evaluate sources and convert what you learn into practice, the information you consume daily will deliver its greatest potential. You’ll know what’s trivial or flashy and can dismiss it with a smile, and what embodies simple, profound craftsmanship that’s worth studying quietly.

Above I explained why you should raise source quality; now I’ll address what constitutes a high-quality source. Is new-media public accounts inherently inferior to books in content quality? Certainly not. Different channels have different strengths; quality is only one dimension, and ranking channels solely by quality is unfair. It’s more appropriate to judge sources by brand. Whether an individual or corporate IP, a good brand’s output is rarely poor, because brand quality correlates with the effort invested in selection, editing, and proofreading. Examples of strong brands include community projects like Aotu and Qiwutuan and publishing houses like Turing, O’Reilly, Huazhang, and Zhanlu.

There is no hierarchy of inherent worth among information channels, nor is there a single omnipotent source. When you assign a channel a meaning beyond its nature, you risk going astray, because no channel is all-capable. It’s like the television era criticized in Amusing Ourselves to Death: people were so enthusiastic about TV they even wanted to rebuild education around it, and most attempts to educate through entertainment failed. Television’s strength was light entertainment; don’t expect it to shoulder broader social responsibilities. After TV we experienced the era of internet portals and then mobile new media. Each era added another option for accessing information—there’s no logic that one must replace another, only a logic of which is best suited for a given purpose.

I’ve also read Wan Weigang’s view that one should read many top conferences and academic papers, which are the highest-quality sources. I agree, but his view is somewhat doctrinaire. He tends to take a scientific-elite perspective. Recently I read his accessible introduction to quantum mechanics; one passage in the introduction stuck with me. He argued that disciplines with “science” in their name aren’t truly scientific, reflecting an insecurity in those fields—for example, computer science.

Last updated