Skip to Content
成為卓越程式設計師的38項必修法則
book

成為卓越程式設計師的38項必修法則

by Pete Goodliffe
May 2015
Intermediate to advanced
376 pages
5h 48m
Chinese
GoTop Information, Inc.
Content preview from 成為卓越程式設計師的38項必修法則
第二章
保持門面
不要被表象欺騙。
—伊索
沒有人喜歡使用亂七八糟的程式碼。沒有人想要陷入參差不齊、不一致的格式,或與雜
亂的命名方式奮戰。這並不好玩,這沒有生產力,這是程式員的煉獄。
我們想要使用良好的程式碼。因此,我們當然在乎程式碼美學,這是最容易判斷一段程
式是否容易使用的方式。幾乎每一本程式設計書籍都會用一章來說明程式碼呈現方式。
你看,這一本也有,很奇怪吧! [Page-7]
可悲的是,程式員太過在乎程式的呈現方式,反而造成爭論。這是掀起聖戰的導火線。
哪一個編輯器是最棒的
1
Tab
vs
空格、大括號的位置、每行幾欄、何時大寫。我有我的
偏好, 你也有你的。
Godwin 定律
說:當 Internet 上的討論串不斷變長時,參與者把對方比喻成納粹主義者
或希特勒的機率會趨於一。
Goodliffe 定律
(首次亮相)說:任何與程式碼的外觀有關的
討論串變長時,這個議題變成沒有結論的機率趨近於一。
好的程式員非常在乎好的程式呈現方式。但他們不會理會這種瑣碎的爭論。讓我們長大
吧!
1 是 Vim。就這樣
8
|
第二章:保持門面
重點
再爭論程式碼的呈現方式了。以健康的態度對待程式的呈現方式。
功能失調的典型程式碼審查,清楚地描述我們看待程式碼外觀的目光短淺。當你拿到一
段程式時,經常會挑剔它的呈現方式(特別是當你大略看過程式時,呈現方式是你唯一 ...
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

精通機器學習|使用Python

精通機器學習|使用Python

Sarah Guido, Andreas C. Mueller
Java性能优化实践:JVM调优策略、工具与技巧

Java性能优化实践:JVM调优策略、工具与技巧

Benjamin J. Evans, James Gough, Chris Newland

Publisher Resources

ISBN: 9789863475699