Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Beautiful Code
SPECIAL OFFER: Upgrade this ebook with O’Reilly
A Note Regarding Supplemental Files
Foreword
Preface
How This Book Is Organized
Conventions Used in This Book
Using Code Examples
How to Contact Us
Safari® Enabled
1. A Regular Expression Matcher
1.1. The Practice of Programming
1.2. Implementation
1.3. Discussion
1.4. Alternatives
1.5. Building on It
1.6. Conclusion
2. Subversion's Delta Editor: Interface As Ontology
2.1. Version Control and Tree Transformation
2.2. Expressing Tree Differences
2.3. The Delta Editor Interface
2.4. But Is It Art?
2.5. Abstraction As a Spectator Sport
2.6. Conclusions
3. The Most Beautiful Code I Never Wrote
3.1. The Most Beautiful Code I Ever Wrote
3.2. More and More with Less and Less
3.3. Perspective
3.3.1. A Bonus Analysis
3.4. What Is Writing?
3.5. Conclusion
3.6. Acknowledgments
4. Finding Things
4.1. On Time
4.2. Problem: Weblog Data
4.2.1. Regular Expressions
4.2.2. Putting Regular Expressions to Work
4.2.3. Content-Addressable Storage
4.2.4. Time to Optimize?
4.3. Problem: Who Fetched What, When?
4.3.1. Binary Search
4.3.2. Binary Search Trade-offs
4.3.3. Escaping the Loop
4.4. Search in the Large
4.4.1. Searching with Postings
4.4.2. Ranking Results
4.4.3. Searching the Web
4.5. Conclusion
5. Correct, Beautiful, Fast (in That Order): Lessons from Designing XML Verifiers
5.1. The Role of XML Validation
5.2. The Problem
5.3. Version 1: The Naïve Implementation
5.4. Version 2: Imitating the BNF Grammar O(N)
5.5. Version 3: First Optimization O(log N)
5.6. Version 4: Second Optimization: Don't Check Twice
5.7. Version 5: Third Optimization O(1)
5.8. Version 6: Fourth Optimization: Caching
5.9. The Moral of the Story
6. Framework for Integrated Test: Beauty Through Fragility
6.1. An Acceptance Testing Framework in Three Classes
6.2. The Challenge of Framework Design
6.3. An Open Framework
6.4. How Simple Can an HTML Parser Be?
6.5. Conclusion
7. Beautiful Tests
7.1. That Pesky Binary Search
7.2. Introducing JUnit
7.3. Nailing Binary Search
7.3.1. Smoking Allowed (and Encouraged)
7.3.2. Pushing the Boundaries
7.3.3. Random Acts of Testing
7.3.4. Performance Anxiety
7.4. Conclusion
8. On-the-Fly Code Generation for Image Processing
9. Top Down Operator Precedence
9.1. JavaScript
9.2. Symbol Table
9.3. Tokens
9.4. Precedence
9.5. Expressions
9.6. Infix Operators
9.7. Prefix Operators
9.8. Assignment Operators
9.9. Constants
9.10. Scope
9.11. Statements
9.12. Functions
9.13. Array and Object Literals
9.14. Things to Do and Think About
10. The Quest for an Accelerated Population Count
10.1. Basic Methods
10.2. Divide and Conquer
10.3. Other Methods
10.4. Sum and Difference of Population Counts of Two Words
10.5. Comparing the Population Counts of Two Words
10.6. Counting the 1-Bits in an Array
10.7. Applications
11. Secure Communication: The Technology Of Freedom
11.1. The Heart of the Start
11.2. Untangling the Complexity of Secure Messaging
11.3. Usability Is the Key
11.4. The Foundation
11.4.1. Design Goals and Decisions
11.4.2. Basic System Design
11.5. The Test Suite
11.6. The Functioning Prototype
11.7. Clean Up, Plug In, Rock On…
11.7.1. Revamping the Mail Store
11.7.2. Persistence of Decryption
11.8. Hacking in the Himalayas
11.8.1. Securing the Code
11.8.2. Auditing Crypt::GPG
11.9. The Invisible Hand Moves
11.10. Speed Does Matter
11.11. Communications Privacy for Individual Rights
11.12. Hacking the Civilization
12. Growing Beautiful Code in BioPerl
12.1. BioPerl and the Bio::Graphics Module
12.1.1. Example of Bio::Graphics Output
12.1.2. Bio::Graphics Requirements
12.2. The Bio::Graphics Design Process
12.2.1. Designing How the Developer Interacts with the Module
12.2.2. Setting Options
12.2.3. Choosing Object Classes
12.2.4. Option Processing
12.2.5. Code Example
12.2.6. Dynamic Options
12.3. Extending Bio::Graphics
12.3.1. Supporting Web Developers
12.3.2. Supporting Publication-Quality Images
12.3.3. Adding New Glyphs
12.4. Conclusions and Lessons Learned
13. The Design of the Gene Sorte
13.1. The User Interface of the Gene Sorter
13.2. Maintaining a Dialog with the User over the Web
13.3. A Little Polymorphism Can Go a Long Way
13.4. Filtering Down to Just the Relevant Genes
13.5. Theory of Beautiful Code in the Large
13.6. Conclusion
14. How Elegant Code Evolves with Hardware The Case of Gaussian Elimination
14.1. The Effects of Computer Architectures on Matrix Algorithms
14.2. A Decompositional Approach
14.3. A Simple Version
14.4. LINPACK's DGEFA Subroutine
14.5. LAPACK DGETRF
14.6. Recursive LU
14.7. ScaLAPACK PDGETRF
14.8. Multithreading for Multi-Core Systems
14.9. A Word About the Error Analysis and Operation Count
14.10. Future Directions for Research
14.11. Further Reading
15. The Long-Term Benefits of Beautiful Design
15.1. My Idea of Beautiful Code
15.2. Introducing the CERN Library
15.3. Outer Beauty
15.4. Inner Beauty
15.4.1. Beauty in Brevity and Simplicity
15.4.2. Beauty in Frugality
15.4.3. Beauty in Flow
15.5. Conclusion
16. The Linux Kernel Driver Model: The Benefits of Working Together
16.1. Humble Beginnings
16.2. Reduced to Even Smaller Bits
16.3. Scaling Up to Thousands of Devices
16.4. Small Objects Loosely Joined
17. Another Level of Indirection
17.1. From Code to Pointers
17.2. From Function Arguments to Argument Pointers
17.3. From Filesystems to Filesystem Layers
17.4. From Code to a Domain-Specific Language
17.5. Multiplexing and Demultiplexing
17.6. Layers Forever?
18. Python's Dictionary Implementation: Being All Things to All People
18.1. Inside the Dictionary
18.2. Special Accommodations
18.2.1. A Special-Case Optimization for Small Hashes
18.2.2. When Special-Casing Is Worth the Overhead
18.2.2.1. The Java implementation: another special-case optimization
18.2.2.2. The C implementation: selecting the storage function dynamically
18.3. Collisions
18.4. Resizing
18.4.1. Determining the New Table Size
18.4.2. A Memory Trade-Off That's Worth It: The Free List
18.5. Iterations and Dynamic Changes
18.6. Conclusion
18.7. Acknowledgments
19. Multidimensional Iterators in NumPy
19.1. Key Challenges in N-Dimensional Array Operations
19.2. Memory Models for an N-Dimensional Array
19.3. NumPy Iterator Origins
19.4. Iterator Design
19.4.1. Iterator Progression
19.4.2. Iterator Termination
19.4.3. Iterator Setup
19.4.4. Iterator Counter Tracking
19.4.5. Iterator Structure
19.5. Iterator Interface
19.6. Iterator Use
19.6.1. Iteration Over All But One Dimension
19.6.2. Multiple Iterations
19.6.3. Anecdotes
19.7. Conclusion
20. A Highly Reliable Enterprise System for NASA's Mars Rover Mission
20.1. The Mission and the Collaborative Information Portal
20.2. Mission Needs
20.3. System Architecture
20.4. Case Study: The Streamer Service
20.4.1. Functionality
20.4.2. Service Architecture
20.5. Reliability
20.5.1. Logging
20.5.2. Monitoring
20.6. Robustness
20.6.1. Dynamic Reconfiguration
20.6.2. Hot Swapping
20.7. Conclusion
21. ERP5: Designing for Maximum Adaptability
21.1. General Goals of ERP
21.2. ERP5
21.3. The Underlying Zope Platform
21.4. ERP5 Project Concepts
21.5. Coding the ERP5 Project
21.6. Conclusion
21.6.1. Acknowledgments
22. A Spoonful of Sewage
23. Distributed Programming with MapReduce
23.1. A Motivating Example
23.2. The MapReduce Programming Model
23.3. Other MapReduce Examples
23.4. A Distributed MapReduce Implementation
23.4.1. Execution Overview
23.5. Extensions to the Model
23.6. Conclusion
23.7. Further Reading
23.8. Acknowledgments
23.9. Appendix: Word Count Solution
24. Beautiful Concurrency
24.1. A Simple Example: Bank Accounts
24.1.1. Bank Accounts Using Locks
24.1.2. Locks Are Bad
24.2. Software Transactional Memory
24.2.1. Side Effects and Input/Output in Haskell
24.2.2. Transactions in Haskell
24.2.3. Implementing Transactional Memory
24.2.4. Blocking and Choice
24.2.5. Summary of Basic STM Operations
24.3. The Santa Claus Problem
24.3.1. Reindeer and Elves
24.3.2. Gates and Groups
24.3.3. The Main Program
24.3.4. Implementing Santa
24.3.5. Compiling and Running the Program
24.4. Reflections on Haskell
24.5. Conclusion
24.6. Acknowledgments
25. Syntactic Abstraction: The syntax-case Expander
25.1. Brief Introduction to syntax-case
25.2. Expansion Algorithm
25.2.1. Representations
25.2.2. Producing Expander Output
25.2.3. Stripping Syntax Objects
25.2.4. Syntax Errors
25.2.5. Structural Predicates
25.2.6. Creating Wraps
25.2.7. Manipulating Environments
25.2.8. Identifier Resolution
25.2.9. The Expander
25.2.10. Core Transformers
25.2.11. Parsing and Constructing Syntax Objects
25.2.12. Comparing Identifiers
25.2.13. Conversions
25.2.14. Starting Expansion
25.3. Example
25.4. Conclusion
26. Labor-Saving Architecture: An Object-Oriented Framework for Networked Software
26.1. Sample Application: Logging Service
26.2. Object-Oriented Design of the Logging Server Framework
26.2.1. Understanding the Commonalities
26.2.2. Accommodating Variation
26.2.3. Tying It All Together
26.3. Implementing Sequential Logging Servers
26.3.1. An Iterative Logging Server
26.3.2. A Reactive Logging Server
26.3.3. Evaluating the Sequential Logging Server Solutions
26.4. Implementing Concurrent Logging Servers
26.4.1. A Thread-per-Connection Logging Server
26.4.2. A Process-per-Connection Logging Server
26.4.3. Evaluating the Concurrent Logging Server Solutions
26.5. Conclusion
27. Integrating Business Partners the RESTful Way
27.1. Project Background
27.2. Exposing Services to External Clients
27.2.1. Define the Service Interface
27.3. Routing the Service Using the Factory Pattern
27.4. Exchanging Data Using E-Business Protocols
27.4.1. Parsing the XML Using XPath
27.4.2. Assembling the XML Response
27.5. Conclusion
28. Beautiful Debugging
28.1. Debugging a Debugger
28.2. A Systematic Process
28.3. A Search Problem
28.4. Finding the Failure Cause Automatically
28.5. Delta Debugging
28.6. Minimizing Input
28.7. Hunting the Defect
28.8. A Prototype Problem
28.9. Conclusion
28.10. Acknowledgments
28.11. Further Reading
29. Treating Code As an Essay
30. When a Button Is All That Connects You to the World
30.1. Basic Design Model
30.2. Input Interface
30.2.1. The Tree
30.2.2. The Long Click
30.2.3. Dynamic Tree Repopulation
30.2.4. Simple Typing
30.2.5. Prediction: Word Completion and Next Word
30.2.6. Templates and Replace
30.2.7. The Cache Implementation
30.2.8. Common Words and Favorites
30.2.9. Retracing Paths
30.2.10. The Typing Buffer, Editing, and Scrolling
30.2.11. The Clipboard
30.2.12. Searching
30.2.13. Macros
30.3. Efficiency of the User Interface
30.4. Download
30.5. Future Directions
31. Emacspeak: The Complete Audio Desktop
31.1. Producing Spoken Output
31.2. Speech-Enabling Emacs
31.2.1. A Simple First-Cut Implementation
31.2.2. Iterating on the First-Cut Implementation
31.2.3. A Brief advice Tutorial
31.2.4. Generating Rich Auditory Output
31.2.4.1. Audio formatting using voice-lock
31.2.4.2. Augmenting Emacs to create aural display lists
31.2.4.3. Audio-formatted output from aural display lists
31.2.5. Using Aural CSS (ACSS) for Styling Speech Output
31.2.6. Adding Auditory Icons
31.2.7. Producing Auditory Icons While Speaking Content
31.2.8. The Calendar: Enhancing Spoken Output with Context-Sensitive Semantics
31.3. Painless Access to Online Information
31.3.1. Basic HTML with Emacs W3 and Aural CSS
31.3.2. The emacspeak-websearch Module for Task-Oriented Search
31.3.3. The Web Command Line and URL Templates
31.3.4. The Advent of Feed Readers
31.4. Summary
31.4.1. Managing Code Complexity Over Time
31.4.2. Conclusion
31.5. Acknowledgments
32. Code in Motion
32.1. On Being "Bookish"
32.2. Alike Looking Alike
32.3. The Perils of Indentation
32.4. Navigating Code
32.5. The Tools We Use
32.6. DiffMerge's Checkered Past
32.7. Conclusion
32.8. Acknowledgments
32.9. Further Reading
33. Writing Programs for "The Book"
33.1. The Nonroyal Road
33.2. Warning to Parenthophobes
33.3. Three in a Row
33.4. The Slippery Slope
33.5. The Triangle Inequality
33.6. Meandering On
33.7. "Duh!"—I Mean "Aha!"
33.8. Conclusion
33.9. Further Reading
A. Afterword
B. Contributors
Colophon
SPECIAL OFFER: Upgrade this ebook with O’Reilly
← Prev
Back
Next →
← Prev
Back
Next →