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堂成长课
127
16
保持简单
简单是复杂的最高境界。
——达
芬奇
你一定听过这个建议:
KISS
Keep it simple, stupid
)。意思就是:“保持简单,笨蛋。”一
个人要有多么愚蠢才会把这当成耳旁风呢?简单无疑是极好的目标,当然应该在代码中努
力实现它。没有哪个程序员愿意处理过于复杂的代码。简单的代码透明、结构清晰、
bug
少、易学易用。
为什么不是所有的代码都这样?
在程序员的世界中,有两种简单:
错误的
正确的
。我们所追求的“简单”并
不是
以最简
单的方式写代码、抄近路、忽略所有烦人的复杂之物(把它们都隐藏起来,希望它们消
失),做一个简简单单的程序员就好。
要是我们要的简单有这么“简单”就好了。但是在现实世界中,很多程序员确实用这种
方式编写简单代码。他们根本不动脑子有些人甚至对自己做错了什么完全没有意识,
对自己正在编写的代码没有充分考虑。对于代码中所有固有的微妙复杂性,他们几乎不
了解。
不动脑筋的方法不能产生简单的代码,而会产生
过于简化
的代码。过于简化的代码错误
重重。由于考虑不周,代码和需求便不能匹配:通常只考虑表面可见的部分,忽略错误
处理,不能处理任何非常规的输入。因此,过于简化的代码是
bug
的“港湾”,至于这些
bug
,大家倾向于用更加随意的代码糊弄过去。这些修复开始堆积在一起,直到代码变成
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