Beautiful Code: Leading Programmers Explain How They Think
Andy Oram, Greg Wilson
- 出版商: O'Reilly Media
- 出版日期: 2007-07-06
- 售價: $1,703
- 貴賓價: 9.5 折 $1,618
- 語言: 英文
- 頁數: 620
- 裝訂: Paperback
- ISBN: 0596510047
- ISBN-13: 9780596510046
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 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
by Greg Wilson
1. A Regular Expression Matcher
by Brian Kernighan
The Practice of Programming
Building on It
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
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
What Is Writing?
4. Finding Things
by Tim Bray
Problem: Weblog Data
Problem: Who Fetched What, When?
Search in the Large
5. Correct, Beautiful, Fast (in That Order): Lessons from Designing XML Verifiers
by Elliotte Rusty Harold
The Role of XML Validation
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?
7. Beautiful Tests
by Alberto Savoia
That Pesky Binary Search
Nailing Binary Search
8. On-the-Fly Code Generation for Image Processing
by Charles Petzold
9. Top Down Operator Precedence
by Douglas Crockford
Array and Object Literals
Things to Do and Think About
10. The Quest for an Accelerated Population Count
by Henry S. Warren, Jr.
Divide and Conquer
Sum and Difference of Population Counts of Two Words
Comparing the Population Counts of Two Words
Counting the 1-Bits in an Array
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 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
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
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
Multithreading for Multi-Core Systems
A Word About the Error Analysis and Operation Count
Future Directions for Research
15. The Long-Term Benefits of Beautiful Design
by Adam Kolawa
My Idea of Beautiful Code
Introducing the CERN Library
16. The Linux Kernel Driver Model: The Benefits of Working Together
by Greg Kroah-Hartman
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
18. Python's Dictionary Implementation: Being All Things to All People
by Andrew Kuchling
Inside the Dictionary
Iterations and Dynamic Changes
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
20. A Highly Reliable Enterprise System for NASA's Mars Rover Mission
by Ronald Mak
The Mission and the Collaborative Information Portal
Case Study: The Streamer Service
21. ERP5: Designing for Maximum Adaptability
by Rogerio Atem de Carvalho and Rafael Monnerat
General Goals of ERP
The Underlying Zope Platform
ERP5 Project Concepts
Coding the ERP5 Project
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
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
25. Syntactic Abstraction: The syntax-case Expander
by R. Kent Dybvig
Brief Introduction to syntax-case
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
27. Integrating Business Partners the RESTful Way
by Andrew Patzer
Exposing Services to External Clients
Routing the Service Using the Factory Pattern
Exchanging Data Using E-Business Protocols
28. Beautiful Debugging
by Andreas Zeller
Debugging a Debugger
A Systematic Process
A Search Problem
Finding the Failure Cause Automatically
Hunting the Defect
A Prototype Problem
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
Efficiency of the User Interface
31. Emacspeak: The Complete Audio Desktop
by T. V. Raman
Producing Spoken Output
Painless Access to Online Information
32. Code in Motion
by Laura Wingerd and Christopher Seiwald
On Being "Bookish"
Alike Looking Alike
The Perils of Indentation
The Tools We Use
DiffMerge's Checkered Past
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
"Duh!"-I Mean "Aha!"
by Andy Oram