Skip to Content
程序员的38堂成长课
book

程序员的38堂成长课

by Pete Goodliffe
January 2022
Beginner to intermediate
314 pages
6h 55m
Chinese
Posts & Telecom Press
Content preview from 程序员的38堂成长课
保持外观整洁
9
/**************************************************
* This is a pretty comment. *
* Note that there are asterisks on the *
* righthand side of the box. Wow; it looks neat. *
* Hope I never have to fix this tiypo. *
**************************************************/
这条注释看起来很漂亮,但是难于维护。如果你要修改注释,则需要重新对齐注释框的右
边界。坦白地讲,这是一种虐待狂式的排版方式,而选用这种排版方式的程序员并不尊重
同事的时间和精力。(或许他们想把修改这段注释变得极其令人厌烦,这样就没有人敢编
辑他们的注释了。)
2.3
 排版
如果一个人想写得清晰,那么他首先应该思路清晰。
——歌德
代码排版的要素包括代码缩进、运算符前后是否加空白、大小写、大括号的位置(可以选
K&R
风格、
Allman
风格、
Whitesmith
风格,或者其他风格),以及争论不休的用“
Tab
空格”缩进。每个要素都有很多选择,每个选择都有合适的理由。只要你选择的排版方
式能够改善代码的结构,更好地反映你的意图,那就是好的选择。
粗略地看一眼你的代码,如果能够看出代码大概的结构,那就是好的排版。相对于争论
大括号应该放在什么位置,还有很多更重要的排版问题值得考虑。下面的几个方面值得 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey
Python应用开发指南

Python应用开发指南

Posts & Telecom Press, Ninad Sathaye
解密金融数据

解密金融数据

Justin Pauley

Publisher Resources

ISBN: 9787115577948