Skip to Content
Bad Data 技術手冊
book

Bad Data 技術手冊

by Q. Ethan McCallum
September 2013
Intermediate to advanced
264 pages
5h
Chinese
GoTop Information, Inc.
Content preview from Bad Data 技術手冊
118
|
第八章:血、汗與尿
最後一個確認,防止一個很嚴重但又很難被偵測的問題。在我年少無知時,當我在人之
間比較一個範圍的化學物質的濃度變量時,便發生過這個問題。當我搜集資料時,我
完全忘記有某些濃度的單位是 μmol/mol,而其他的單位是使用 nmol/mol。其中有一些
結果我還很興奮的回報給上千個人。儘管當時我非常不好意思,幸運的是當時有個化
學家看到了我的錯誤。他們的經驗正確的告訴他們,我的數字是不太合理的。而我用
來防止這個問題再次發生的方法就是,將單位包含進變數名稱中。寫
concentration_
nmol_per_mol
比寫
concentration
需要更多的字元輸入,但我更不想要產生出不正確的
結果。
活得快,死得早,並且留下一個好看的原始碼容器
屍體
在變數名稱中包含單位,是一個幫助我從「撰寫程式的數學家」變成「程式設計師」的
概念的一部份。這個概念是使用設計風格守則。看起來漂亮的程式碼,代表你能夠在六
個月後再次看它時也能輕易瞭解,並且也是讓你能夠毫不害羞給予別人的程式碼。當
然,內容也很重要,但不要低估了好看的程式碼的重要性。
10
如同在資料儲存時增加輸
入結構與限制的方法,這些也是撰寫程式時的好想法。
多數的設計風格守則會描述應該要如何為變數以及函式命名(通常是
camelCase
lower_under_case
,變數為名詞而函式為動詞),空白要如何被使用(你想要
x + y
還是
x+y
呢?大括號應該要跟宣告函式在同一行還是下一行呢?),或是程式檔案中的內容順
序為何。這些特定的規則都不盡相同,而你可能會開始想要使用哪種 ...
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

RxJava反应式编程

RxJava反应式编程

Tomasz Nurkiewicz, Ben Christensen
高效能PYTHON程式設計

高效能PYTHON程式設計

Micha Gorelick, Ian Ozsvald
Kubernetes编程

Kubernetes编程

Michael Hausenblas, Stefan Schimanski

Publisher Resources

ISBN: 9789862768952