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項必修法則
12
|
第二章:保持門面
在類別宣告中,分組可以表示為:
class Example
{
public:
Example(); // 首先是存留期管理
~Example();
void doMostImportantThing(); // 這會開啟一個新的“段落”
void doSomethingRelated(); // 這裡的每一行都像是一個句子
void somethingDifferent(); // 這是另一個段落
void aRelatedThing();
private:
int privateStuffComesLast;
};
請優先編寫較短的程式碼區塊。不要在一個函式裡面寫入五個“段落”。請考慮將它分
成五個函式,並為它們選一個好名字。
一致性
不要過於重視排版樣式。選一個,並持續使用它就好。最好使用最適合你的語言的典型
表達風格。請遵循標準程式庫的風格。
使用與團隊的其他人相同的排版方式來編寫程式。不要因為你認為自己的風格比較漂亮
或比較好而使用它。如果你的專案沒有一致性,考慮制定
編程標準或風格指南
。它不
見得需要是冗長、嚴苛的文件,只要用一些大家認同的排版原則來凝聚團隊共識就可以
了。在這個情況下,編程標準必須是彼此認同的,而不是強迫彼此。[Page-12]
如果你使用的檔案的排版方式與專案其他檔案不同,請使用那個檔案裡面的排版格式。
確保整個團隊的 IDE 與原始碼編輯器都使用同樣的設定。設定相同的定位停駐點大小
tab stop size)。設定完全相同的大括號位置及註解排列方式。設定相同的換行選項 ...
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