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項必修法則
第十六章
保持簡單
簡單是終極的複雜。
- Leonardo da Vinci
你以前聽過這樣的建議: "KISS"
Keep it simple, stupid
保持簡單,愚蠢)。到底你有
多愚蠢,才會把
做錯?簡單化無疑是一個很棒的目標,你當然要在你的程式碼中努力
做到這一點。沒有程式員想要與過度複雜的程式共事。簡單的程式碼是透明的,它的結
構很清楚,你不會隱藏 bug,它很容易學習,而且容易使用。
那麼,為什麼不是所有程式都是如此?
在開發圈,有兩種簡單化:
錯誤
的,和
正確
的。我們想要達成的“簡單化”指的
不是
用你最輕鬆的方式來寫程式、抄近路、忽略所有令人討厭的複雜事物(把它掃到地毯下
面,希望它可以離開),完全成為一位程式傻瓜。
喔,如果真有這麼容易的話。現實世界中有太多程式員
確實
會用這種方式來寫程式。他
們的頭腦不會參與其中。他們其中有些人甚至沒有意識到他們做錯事情了,他們只是沒
有想太多就開始編寫,沒有意識到所有固有的微妙複雜性。
這種盲目的做法不會產生簡單的程式,而是過度簡化程式。簡單過頭的程式是不正確的
程式。因為它是一種病態,仔細想想,它的動作無法符合需求—通常它只會解決明顯的
“主要狀況”,忽略錯誤的條件,或無法正確地處理較不常出現的輸入。因此,過度簡
化的程式會窩藏錯誤。它們都是刻意被用來掩蓋更多不良的簡化程式碼的劣作。這些修
補程式會開始一個一個堆積起來,直到程式變成可怕的一團混亂,這跟具備良好的結構
的簡單程式完全相反。
152
| 第十六章:保持簡單
簡化永遠不是不正確程式的藉口。[Page-146] ...
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