Beautiful Code: Leading Programmers Explain How They Think (Paperback)
暫譯: 美麗的程式碼:頂尖程式設計師解釋他們的思維方式 (平裝本)

Andy Oram, Greg Wilson

  • 出版商: O'Reilly
  • 出版日期: 2007-07-31
  • 定價: $1,675
  • 售價: 9.5$1,591
  • 語言: 英文
  • 頁數: 620
  • 裝訂: Paperback
  • ISBN: 0596510047
  • ISBN-13: 9780596510046
  • 相關分類: Design Pattern 軟體工程
  • 立即出貨 (庫存 < 3)

買這商品的人也買了...

商品描述

Description

How do the experts solve difficult problems in software development? In this unique and insightful book, leading computer scientists offer case studies that reveal how they found unusual, carefully designed solutions to high-profile projects. You will be able to look over the shoulder of major coding and design experts to see problems through their eyes.

This is not simply another design patterns book, or another software engineering treatise on the right and wrong way to do things. The authors think aloud as they work through their project's architecture, the tradeoffs made in its construction, and when it was important to break rules. Beautiful Code is an opportunity for master coders to tell their story. All author royalties will be donated to Amnesty International.

The book includes:

Chapter 1, A Regular Expression Matcher, by Brian Kernighan, shows how deep insight into a language and a problem can lead to a concise and elegant solution.

Chapter 2, Subversion's Delta Editor: Interface as Ontology, by Karl Fogel, starts with a well-chosen abstraction and demonstrates its unifying effects on the system's further development.

Chapter 3, The Most Beautiful Code I Never Wrote, by Jon Bentley, suggests how to measure a procedure without actually executing it.

Chapter 4, Finding Things, by Tim Bray, draws together many strands in Computer Science in an exploration of a problem that is fundamental to many computing tasks.

Chapter 5, Correct, Beautiful, Fast (In That Order): Lessons From Designing XML Verifiers, by Elliotte Rusty Harold, reconciles the often conflicting goals of thoroughness and good performance.

Chapter 6, Framework for Integrated Test: Beauty through Fragility, by Michael Feathers, presents an example that breaks the rules and achieves its own elegant solution.

Chapter 7, Beautiful Tests, by Alberto Savoia, shows how a broad, creative approach to testing can not only eliminate bugs but turn you into a better programmer.

Chapter 8, On-the-Fly Code Generation for Image Processing, by Charles Petzold, drops down a level to improve performance while maintaining portability.

Chapter 9, Top-Down Operator Precedence, by Douglas Crockford, revives an almost forgotten parsing technique and shows its new relevance to the popular JavaScript language.

Chapter 10, The Quest for an Accelerated Population Count, by Henry S. Warren, Jr., reveals the impact that some clever algorithms can have on even a seemingly simple problem.

Chapter 11, Secure Communication: The Technology of Freedom, by Ashish Gulhati, discusses the directed evolution of a secure messaging application that was designed to make sophisticated but often confusing cryptographic technology intuitively accessible to users.

Chapter 12, Growing Beautiful Code in BioPerl, by Lincoln Stein, shows how the combination of a flexible language and a custom-designed module can make it easy for people with modest programming skills to create powerful visualizations for their data.

Chapter 13, The Design of the Gene Sorter, by Jim Kent, combines simple building blocks to produce a robust and valuable tool for gene researchers.

Chapter 14, How Elegant Code Evolves With Hardware: The Case Of Gaussian Elimination, by Jack Dongarra and Piotr Luszczek, surveys the history of LINPACK and related major software packages, to show how assumptions must constantly be re-evaluated in the face of new computing architectures.

Chapter 15, The Long-Term Benefits of Beautiful Design, by Adam Kolawa, explains how attention to good design principles many decades ago helped CERN's widely used mathematical library (the predecessor of LINPACK) stand the test of time.

Chapter 16, The Linux Kernel Driver Model: The Benefits of Working Together, by Greg Kroah-Hartman, explains how many efforts by different collaborators to solve different problems led to the successful evolution of a complex, multithreaded system.

Chapter 17, Another Level of Indirection, by Diomidis Spinellis, shows how the flexibility and maintainability of the FreeBSD kernel is promoted by abstracting operations done in common by many drivers and filesystem modules.

Chapter 18, Python's Dictionary Implementation: Being All Things to All People, by Andrew Kuchling, explains how a careful design combined with accommodations for a few special cases allows a language feature to support many different uses.

Chapter 19, Multi-Dimensional Iterators in NumPy, by Travis E. Oliphant, takes you through the design steps that succeed in hiding complexity under a simple interface.

Chapter 20, A Highly Reliable Enterprise System for NASA's Mars Rover Mission, by Ronald Mak, uses industry standards, best practices, and Java technologies to meet the requirements of a NASA expedition where reliability cannot be in doubt.

Chapter 21, ERP5: Designing for Maximum Adaptability, by Rogerio Atem de Carvalho and Rafael Monnerat, shows how a powerful ERP system can be developed with free software tools and a flexible architecture.

Chapter 22, A Spoonful of Sewage, by Bryan Cantrill, lets the reader accompany the author through a hair-raising bug scare and a clever solution that violated expectations.

Chapter 23, Distributed Programming with MapReduce, by Jeff Dean and Sanjay Ghemawat, describes a system that provides an easy-to-use programming abstraction for large-scale distributed data processing at Google that automatically handles many difficult aspects of distributed computation, including automatic parallelization, load balancing, and failure handling.

Chapter 24, Beautiful Concurrency, by Simon Peyton Jones, removes much of the difficulty of parallel program through Software Transactional Memory, demonstrated here using Haskell.

Chapter 25, Syntactic Abstraction: The syntax-case Expander, by Kent Dybvig, shows how macros-a key feature of many languages and systems-can be protected in Scheme from producing erroneous output.

Chapter 26, Labor-Saving Architecture: An Object-Oriented Framework for Networked Software, by William Otte and Douglas C. Schmidt, applies a range of standard object-oriented design techniques, such as patterns and frameworks, to distributed logging to keep the system flexible and modular.

Chapter 27, Integrating Business Partners the RESTful Way, by Andrew Patzer, demonstrates a designer's respect for his programmers by matching the design of a B2B web service to its requirements.

Chapter 28, Beautiful Debugging, by Andreas Zeller, shows how a disciplined approach to validating code can reduce the time it takes to track down errors.

Chapter 29, Treating Code as an Essay, by Yukihiro Matsumoto, lays out some challenging principles that drove his design of the Ruby programming language, and that, by extension, will help produce better software in general.

Chapter 30, When a Button Is All That Connects You to the World, by Arun Mehta, takes you on a tour through the astounding interface design choices involved in a text editing system that allow people with severe motor disabilities, like Professor Stephen Hawking, to communicate via a computer.

Chapter 31, Emacspeak: The Complete Audio Desktop, by TV Raman, shows how Lisp's advice facility can be used with Emacs to address a general need-generating rich spoken output-that cuts across all aspects of the Emacs environment, without modifying the underlying source code of a large software system.

Chapter 32, Code in Motion, by Laura Wingerd and Christopher Seiwald, lists some simple rules that have unexpectedly strong impacts on programming accuracy.

Chapter 33, Writing Programs for "The Book," by Brian Hayes, explores the frustrations of solving a seemingly simple problem in computational geometry, and its surprising resolution.

Table of Contents

Foreword
by Greg Wilson

Preface

1. A Regular Expression Matcher
by Brian Kernighan

     The Practice of Programming

     Implementation

     Discussion

     Alternatives

     Building on It

     Conclusion

2. Subversion's Delta Editor: Interface As Ontology
by Karl Fogel

     Version Control and Tree Transformation

     Expressing Tree Differences

     The Delta Editor Interface

     But Is It Art?

     Abstraction As a Spectator Sport

     Conclusions

3. The Most Beautiful Code I Never Wrote
by Jon Bentley

     The Most Beautiful Code I Ever Wrote

     More and More with Less and Less

     Perspective

     What Is Writing?

     Conclusion

     Acknowledgments

4. Finding Things
by Tim Bray

     On Time

     Problem: Weblog Data

     Problem: Who Fetched What, When?

     Search in the Large

     Conclusion

5. Correct, Beautiful, Fast (in That Order): Lessons from Designing XML Verifiers
by Elliotte Rusty Harold

     The Role of XML Validation

     The Problem

     Version 1: The Naïve Implementation

     Version 2: Imitating the BNF Grammar O(N)

     Version 3: First Optimization O(log N)

     Version 4: Second Optimization: Don't Check Twice

     Version 5: Third Optimization O(1)

     Version 6: Fourth Optimization: Caching

     The Moral of the Story

6. Framework for Integrated Test: Beauty Through Fragility
by Michael Feathers

     An Acceptance Testing Framework in Three Classes

     The Challenge of Framework Design

     An Open Framework

     How Simple Can an HTML Parser Be?

     Conclusion

7. Beautiful Tests
by Alberto Savoia

     That Pesky Binary Search

     Introducing JUnit

     Nailing Binary Search

     Conclusion

8. On-the-Fly Code Generation for Image Processing
by Charles Petzold

9. Top Down Operator Precedence
by Douglas Crockford

     JavaScript

     Symbol Table

     Tokens

     Precedence

     Expressions

     Infix Operators

     Prefix Operators

     Assignment Operators

     Constants

     Scope

     Statements

     Functions

     Array and Object Literals

     Things to Do and Think About

10. The Quest for an Accelerated Population Count
by Henry S. Warren, Jr.

     Basic Methods

     Divide and Conquer

     Other Methods

     Sum and Difference of Population Counts of Two Words

     Comparing the Population Counts of Two Words

     Counting the 1-Bits in an Array

     Applications

11. Secure Communication: The Technology Of Freedom
by Ashish Gulhati

     The Heart of the Start

     Untangling the Complexity of Secure Messaging

     Usability Is the Key

     The Foundation

     The Test Suite

     The Functioning Prototype

     Clean Up, Plug In, Rock On . . .

     Hacking in the Himalayas

     The Invisible Hand Moves

     Speed Does Matter

     Communications Privacy for Individual Rights

     Hacking the Civilization

12. Growing Beautiful Code in BioPerl
by Lincoln Stein

     BioPerl and the Bio::Graphics Module

     The Bio::Graphics Design Process

     Extending Bio::Graphics

     Conclusions and Lessons Learned

13. The Design of the Gene Sorter
by Jim Kent

     The User Interface of the Gene Sorter

     Maintaining a Dialog with the User over the Web

     A Little Polymorphism Can Go a Long Way

     Filtering Down to Just the Relevant Genes

     Theory of Beautiful Code in the Large

     Conclusion

14. How Elegant Code Evolves with Hardware: The Case of Gaussian Elimination
by Jack Dongarra and Piotr Luszczek

     The Effects of Computer Architectures on Matrix Algorithms

     A Decompositional Approach

     A Simple Version

     LINPACK's DGEFA Subroutine

     LAPACK DGETRF

     Recursive LU

     ScaLAPACK PDGETRF

     Multithreading for Multi-Core Systems

     A Word About the Error Analysis and Operation Count

     Future Directions for Research

     Further Reading

15. The Long-Term Benefits of Beautiful Design
by Adam Kolawa

     My Idea of Beautiful Code

     Introducing the CERN Library

     Outer Beauty

     Inner Beauty

     Conclusion

16. The Linux Kernel Driver Model: The Benefits of Working Together
by Greg Kroah-Hartman

     Humble Beginnings

     Reduced to Even Smaller Bits

     Scaling Up to Thousands of Devices

     Small Objects Loosely Joined

17. Another Level of Indirection
by Diomidis Spinellis

     From Code to Pointers

     From Function Arguments to Argument Pointers

     From Filesystems to Filesystem Layers

     From Code to a Domain-Specific Language

     Multiplexing and Demultiplexing

     Layers Forever?

18. Python's Dictionary Implementation: Being All Things to All People
by Andrew Kuchling

     Inside the Dictionary

     Special Accommodations

     Collisions

     Resizing

     Iterations and Dynamic Changes

     Conclusion

     Acknowledgments

19. Multidimensional Iterators in NumPy
by Travis E. Oliphant

     Key Challenges in N-Dimensional Array Operations

     Memory Models for an N-Dimensional Array

     NumPy Iterator Origins

     Iterator Design

     Iterator Interface

     Iterator Use

     Conclusion

20. A Highly Reliable Enterprise System for NASA's Mars Rover Mission
by Ronald Mak

     The Mission and the Collaborative Information Portal

     Mission Needs

     System Architecture

     Case Study: The Streamer Service

     Reliability

     Robustness

     Conclusion

21. ERP5: Designing for Maximum Adaptability
by Rogerio Atem de Carvalho and Rafael Monnerat

     General Goals of ERP

     ERP5

     The Underlying Zope Platform

     ERP5 Project Concepts

     Coding the ERP5 Project

     Conclusion

22. A Spoonful of Sewage
by Bryan Cantrill

23. Distributed Programming with MapReduce
by Jeffrey Dean and Sanjay Ghemawat

     A Motivating Example

     The MapReduce Programming Model

     Other MapReduce Examples

     A Distributed MapReduce Implementation

     Extensions to the Model

     Conclusion

     Further Reading

     Acknowledgments

     Appendix: Word Count Solution

24. Beautiful Concurrency
by Simon Peyton Jones

     A Simple Example: Bank Accounts

     Software Transactional Memory

     The Santa Claus Problem

     Reflections on Haskell

     Conclusion

     Acknowledgments

25. Syntactic Abstraction: The syntax-case Expander
by R. Kent Dybvig

     Brief Introduction to syntax-case

     Expansion Algorithm

     Example

     Conclusion

26. Labor-Saving Architecture: An Object-Oriented Framework for Networked Software
by William R. Otte and Douglas C. Schmidt

     Sample Application: Logging Service

     Object-Oriented Design of the Logging Server Framework

     Implementing Sequential Logging Servers

     Implementing Concurrent Logging Servers

     Conclusion

27. Integrating Business Partners the RESTful Way
by Andrew Patzer

     Project Background

     Exposing Services to External Clients

     Routing the Service Using the Factory Pattern

     Exchanging Data Using E-Business Protocols

     Conclusion

28. Beautiful Debugging
by Andreas Zeller

     Debugging a Debugger

     A Systematic Process

     A Search Problem

     Finding the Failure Cause Automatically

     Delta Debugging

     Minimizing Input

     Hunting the Defect

     A Prototype Problem

     Conclusion

     Acknowledgments

     Further Reading

29. Treating Code As an Essay
by Yukihiro Matsumoto

30. When a Button Is All That Connects You to the World
by Arun Mehta

     Basic Design Model

     Input Interface

     Efficiency of the User Interface

     Download

     Future Directions

31. Emacspeak: The Complete Audio Desktop
by T. V. Raman

     Producing Spoken Output

     Speech-Enabling Emacs

     Painless Access to Online Information

     Summary

     Acknowledgments

32. Code in Motion
by Laura Wingerd and Christopher Seiwald

     On Being "Bookish"

     Alike Looking Alike

     The Perils of Indentation

     Navigating Code

     The Tools We Use

     DiffMerge's Checkered Past

     Conclusion

     Acknowledgments

     Further Reading

33. Writing Programs for "The Book"
by Brian Hayes

     The Nonroyal Road

     Warning to Parenthophobes

     Three in a Row

     The Slippery Slope

     The Triangle Inequality

     Meandering On

     "Duh!"-I Mean "Aha!"

     Conclusion

     Further Reading

Afterword
by Andy Oram

Contributors

index

商品描述(中文翻譯)

### 描述

專家們是如何解決軟體開發中的困難問題的?在這本獨特且具洞察力的書中,領先的計算機科學家提供了案例研究,揭示他們如何找到不尋常且精心設計的解決方案來應對高知名度的專案。您將能夠透過主要的編碼和設計專家的視角來看待問題。

這不僅僅是另一本設計模式的書,或是關於正確與錯誤做法的軟體工程論文。作者們在思考他們專案的架構、建設過程中的權衡,以及何時打破規則時,進行了深入的思考。《美麗的程式碼》是大師級程式設計師講述他們故事的機會。所有作者的版稅將捐贈給國際特赦組織。

本書包括:

第1章,《正規表達式匹配器》,由Brian Kernighan撰寫,展示了對語言和問題的深刻洞察如何導致簡潔而優雅的解決方案。

第2章,《Subversion的Delta編輯器:作為本體的介面》,由Karl Fogel撰寫,從一個精心選擇的抽象開始,展示了其對系統進一步發展的統一效果。

第3章,《我從未寫過的最美麗的程式碼》,由Jon Bentley撰寫,建議如何在不實際執行的情況下衡量一個過程。

第4章,《尋找事物》,由Tim Bray撰寫,將計算機科學中的許多線索結合在一起,探索一個對許多計算任務至關重要的問題。

第5章,《正確、美麗、快速(按此順序):設計XML驗證器的教訓》,由Elliotte Rusty Harold撰寫,調和了徹底性和良好性能之間經常衝突的目標。

第6章,《集成測試的框架:通過脆弱性獲得美感》,由Michael Feathers撰寫,展示了一個打破規則並實現自己優雅解決方案的例子。

第7章,《美麗的測試》,由Alberto Savoia撰寫,展示了廣泛而創造性的測試方法如何不僅消除錯誤,還能讓您成為更好的程式設計師。

第8章,《即時圖像處理的程式碼生成》,由Charles Petzold撰寫,降低了一個層級以提高性能,同時保持可攜性。

第9章,《自上而下的運算子優先級》,由Douglas Crockford撰寫,復興了一種幾乎被遺忘的解析技術,並展示了其對流行的JavaScript語言的新相關性。

第10章,《加速人口計數的探索》,由Henry S. Warren, Jr.撰寫,揭示了一些巧妙算法對看似簡單問題的影響。

第11章,《安全通信:自由的技術》,由Ashish Gulhati撰寫,討論了一個安全消息應用的定向演變,旨在使複雜但常常令人困惑的加密技術對用戶直觀可及。

第12章,《在BioPerl中成長美麗的程式碼》,由Lincoln Stein撰寫,展示了靈活語言和自定義模組的結合如何使擁有適度程式設計技能的人能夠為其數據創建強大的可視化。

第13章,《基因排序器的設計》,由Jim Kent撰寫,結合簡單的構建塊,為基因研究人員提供了一個穩健且有價值的工具。

第14章,《優雅程式碼如何隨硬體演變:高斯消去的案例》,由Jack Dongarra和Piotr Luszczek撰寫,回顧了LINPACK及相關主要軟體包的歷史,展示了在面對新計算架構時,假設必須不斷重新評估。

第15章,《美麗設計的長期效益》,由Adam Kolawa撰寫,解釋了幾十年前對良好設計原則的重視如何幫助CERN廣泛使用的數學庫(LINPACK的前身)經受住時間的考驗。

第16章,《Linux內核驅動模型:合作的好處》,由Greg Kroah-Hartman撰寫,解釋了不同合作者為解決不同問題所做的多項努力如何導致一個複雜的多執行緒系統的成功演變。

第17章,《另一層間接》,由Diomidis Spinellis撰寫,展示了FreeBSD內核的靈活性和可維護性是如何通過抽象許多驅動程式和檔案系統模組共同執行的操作來促進的。

第18章,《Python的字典實現:為所有人而生》,由Andrew Kuchling撰寫,解釋了如何通過仔細的設計結合對少數特殊情況的考慮,使語言特性能夠支持多種不同的用途。

第19章,《NumPy中的多維迭代器》,由Travis E. Oliphant撰寫,帶您了解成功隱藏複雜性下簡單介面的設計步驟。

第20章,《NASA火星探測器任務的高可靠性企業系統》,由Ronald Mak撰寫,使用行業標準、最佳實踐和Java技術來滿足NASA探險的要求,可靠性無可置疑。

第21章,《ERP5:為最大適應性而設計》,由Rogerio Atem de Carvalho和Rafael Monnerat撰寫,展示了如何使用自由軟體工具和靈活架構開發一個強大的ERP系統。

第22章,《一勺污水》,由Bryan Cantrill撰寫,讓讀者陪伴作者經歷一場驚心動魄的錯誤驚嚇和一個違反預期的巧妙解決方案。

第23章,《使用MapReduce的分散式程式設計》,由Jeff Dean和Sanjay Ghemawat撰寫,描述了一個系統,為Google的大規模分散式數據處理提供易於使用的程式設計抽象,自動處理分散計算的許多困難方面,包括自動平行化、負載平衡和故障處理。

第24章,《美麗的並發性》,由Simon Peyton Jones撰寫,通過軟體事務記憶體消除了平行程式的許多困難,這裡使用Haskell進行演示。

第25章,《語法抽象:語法案例擴展器》,由Kent Dybvig撰寫,展示了如何在Scheme中保護宏這一許多語言和系統的關鍵特性,以防止產生錯誤的輸出。

第26章,《節省勞動的架構:一個面向對象的網路軟體框架》,由William Otte和Douglas C. Schmidt撰寫,應用一系列標準的面向對象設計技術,如模式和框架,來進行分散式日誌記錄,以保持系統的靈活性和模組化。

第27章,《以RESTful方式整合商業夥伴》,由Andrew Patzer撰寫,展示了一位設計師對其程式設計師的尊重,通過將B2B網路服務的設計與其需求相匹配。

第28章,《美麗的除錯》,由Andreas Zeller撰寫,展示了對驗證程式碼的紀律性方法如何減少追蹤錯誤所需的時間。

第29章,《將程式碼視為一篇論文》,由松本行弘撰寫,闡述了一些挑戰性的原則,這些原則驅動了他對Ruby程式語言的設計,並且,通過擴展,將有助於產生更好的軟體。

第30章,《當一個按鈕是您與世界的唯一聯繫》,由Arun Mehta撰寫,帶您參觀一個文本編輯系統中令人驚訝的介面設計選擇,這些選擇使得像史蒂芬·霍金教授這樣的重度運動障礙者能夠通過計算機進行交流。

第31章,《Emacspeak:完整的音頻桌面》,由TV Raman撰寫,展示了如何使用Lisp的建議功能與Emacs結合,以滿足一個普遍需求——生成豐富的語音輸出——這一需求貫穿Emacs環境的所有方面,而無需修改大型軟體系統的底層源代碼。

第32章,《運動中的程式碼》,由Laura Wingerd和Christopher Seiwald撰寫,列出了一些簡單的規則,這些規則對程式設計的準確性有意想不到的強大影響。

第33章,《為「這本書」編寫程式》,由Brian Hayes撰寫,探討了解決計算幾何中一個看似簡單問題的挫折,以及其驚人的解決方案。

### 目錄

**前言**
由Greg Wilson撰寫

**序言**

**1. 正規表達式匹配器**
由Brian Kernighan撰寫
     程式設計實踐
     實作
     討論
     替代方案
     基於此的建設
     結論

**2. Subversion的Delta編輯器:作為本體的介面**
由Karl Fogel撰寫
     版本控制與樹形轉換
     表達樹形差異
     Delta編輯器介面
     但這是藝術嗎?
     抽象作為觀賞運動
     結論

**3. 我從未寫過的最美麗的程式碼**
由Jon Bentley撰寫
     我寫過的最美麗的程式碼
     越來越多,越來越少
     視角
     什麼是寫作?
     結論
     致謝

**4. 尋找事物**
由Tim Bray撰寫
     準時
     問題:網誌數據
     問題:誰在什麼時候獲取了什麼?
     大範圍搜索
     結論

**5. 正確、美麗、快速(按此順序):設計XML驗證器的教訓**
由Elliotte Rusty Harold撰寫
     XML驗證的角色
     問題
     版本1:天真的實作
     版本2:模仿BNF文法O(N)
     版本3:第一次優化O(log N)
     版本4:第二次優化:不檢查兩次
     版本5:第三次優化O(1)
     版本6:第四次優化:快取
     故事的道德

最後瀏覽商品 (20)