| Figures | xiii | 
 | Tables | xix | 
 | Foreword | xxi | 
 | Preface | xxv | 
|   | 
| 1 | Introduction |  1 | 
| 1.1 | Why and How to Read Code  | 2 | 
| 1.1.1 | Code as Literature  | 2 | 
| 1.1.2 | Code as Exemplar  | 5 | 
| 1.1.3 | Maintenance  | 6 | 
| 1.1.4 | Evolution  | 7 | 
| 1.1.5 | Reuse  | 9 | 
| 1.1.6 | Inspections  | 9 | 
| 1.2 | How to Read This Book  | 10 | 
| 1.2.1 | Typographical Conventions  | 10 | 
| 1.2.2 | Diagrams  | 12 | 
| 1.2.3 | Exercises  | 13 | 
| 1.2.4 | Supplementary Material  | 14 | 
| 1.2.5 | Tools  | 14 | 
| 1.2.6 | Outline  | 15 | 
| 1.2.7 | The Great Language Debate  | 15 | 
 | Further Reading  | 17 | 
|   | 
| 2 | 
Basic Programming Elements
  | 
19 (PDF 251K)
 | 
| 2.1 | A Complete Program  | 19 | 
| 2.2 | Functions and Global Variables  | 25 | 
| 2.3 | while Loops, Conditions, and Blocks  | 28 | 
| 2.4 | switch Statements  | 32 | 
| 2.5 | for Loops  | 34 | 
| 2.6 | break and continue Statements  | 37 | 
| 2.7 | Character and Boolean Expressions  | 39 | 
| 2.8 | goto Statements  | 43 | 
| 2.9 | Refactoring in the Small  | 45 | 
| 2.10 | do Loops and Integer Expressions  | 51 | 
| 2.11 | Control Structures Revisited  | 54 | 
 | Further Reading  | 60 | 
|   | 
| 3 | Advanced C Data Types  | 61 | 
| 3.1 | Pointers  | 61 | 
| 3.1.1 | Linked Data Structures  | 62 | 
| 3.1.2 | Dynamic Allocation of Data Structures  | 62 | 
| 3.1.3 | Call by Reference  | 63 | 
| 3.1.4 | Data Element Access  | 65 | 
| 3.1.5 | Arrays as Arguments and Results  | 65 | 
| 3.1.6 | Function Pointers  | 67 | 
| 3.1.7 | Pointers as Aliases  | 70 | 
| 3.1.8 | Pointers and Strings  | 72 | 
| 3.1.9 | Direct Memory Access  | 74 | 
| 3.2 | Structures  | 75 | 
| 3.2.1 | Grouping Together Data Elements  | 75 | 
| 3.2.2 | Returning Multiple Data Elements from a Function  | 76 | 
| 3.2.3 | Mapping the Organization of Data  | 76 | 
| 3.2.4 | Programming in an Object-Oriented Fashion  | 78 | 
| 3.3 | Unions  | 80 | 
| 3.3.1 | Using Storage Efficiently  | 80 | 
| 3.3.2 | Implementing Polymorphism  | 81 | 
| 3.3.3 | Accessing Different Internal Representations  | 82 | 
| 3.4 | Dynamic Memory Allocation  | 84 | 
| 3.4.1 | Managing Free Memory  | 87 | 
| 3.4.2 | Structures with Dynamically Allocated Arrays  | 89 | 
| 3.5 | typedef Declarations  | 91 | 
 | Further Reading  | 93 | 
|   | 
| 4 | C Data Structures  | 95 | 
| 4.1 | Vectors  | 96 | 
| 4.2 | Matrices and Tables  | 101 | 
| 4.3 | Stacks  | 105 | 
| 4.4 | Queues  | 107 | 
| 4.5 | Maps  | 111 | 
| 4.5.1 | Hash Tables  | 113 | 
| 4.6 | Sets  | 116 | 
| 4.7 | Linked Lists  | 117 | 
| 4.8 | Trees  | 125 | 
| 4.9 | Graphs  | 131 | 
| 4.9.1 | Node Storage  | 131 | 
| 4.9.2 | Edge Representation  | 134 | 
| 4.9.3 | Edge Storage  | 137 | 
| 4.9.4 | Graph Properties  | 139 | 
| 4.9.5 | Hidden Structures  | 139 | 
| 4.9.6 | Other Representations  | 140 | 
 | Further Reading  | 140 | 
|   | 
| 5 | Advanced Control Flow  | 143 | 
| 5.1 | Recursion  | 143 | 
| 5.2 | Exceptions  | 150 | 
| 5.3 | Parallelism  | 154 | 
| 5.3.1 | Hardware and Software Parallelism  | 154 | 
| 5.3.2 | Control Models  | 156 | 
| 5.3.3 | Thread Implementations  | 162 | 
| 5.4 | Signals  | 165 | 
| 5.5 | Nonlocal Jumps  | 169 | 
| 5.6 | Macro Substitution  | 172 | 
 | Further Reading  | 177 | 
|   | 
| 6 | Tackling Large Projects  | 179 | 
| 6.1 | Design and Implementation Techniques  | 179 | 
| 6.2 | Project Organization  | 181 | 
| 6.3 | The Build Process and Makefiles  | 189 | 
| 6.4 | Configuration  | 197 | 
| 6.5 | Revision Control  | 202 | 
| 6.6 | Project-Specific Tools  | 210 | 
| 6.7 | Testing  | 215 | 
 | Further Reading  | 224 | 
|   | 
| 7 | Coding Standards and Conventions  | 225 | 
| 7.1 | File Names and Organization  | 225 | 
| 7.2 | Indentation  | 228 | 
| 7.3 | Formatting  | 230 | 
| 7.4 | Naming Conventions  | 234 | 
| 7.5 | Programming Practices  | 237 | 
| 7.6 | Process Standards  | 239 | 
 | Further Reading  | 240 | 
|   | 
| 8 | Documentation  | 241 | 
| 8.1 | Documentation Types  | 241 | 
| 8.2 | Reading Documentation  | 243 | 
| 8.3 | Documentation Problems  | 254 | 
| 8.4 | Additional Documentation Sources  | 256 | 
| 8.5 | Common Open-Source Documentation Formats  | 260 | 
 | Further Reading  | 266 | 
|   | 
| 9 | Architecture  | 267 | 
| 9.1 | System Structures  | 268 | 
| 9.1.1 | Centralized Repository and Distributed Approaches  | 268 | 
| 9.1.2 | Data-Flow Architectures  | 273 | 
| 9.1.3 | Object-Oriented Structures  | 275 | 
| 9.1.4 | Layered Architectures  | 279 | 
| 9.1.5 | Hierarchies  | 282 | 
| 9.1.6 | Slicing  | 283 | 
| 9.2 | Control Models  | 285 | 
| 9.2.1 | Event-Driven Systems  | 285 | 
| 9.2.2 | System Manager  | 289 | 
| 9.2.3 | State Transition  | 291 | 
| 9.3 | Element Packaging  | 292 | 
| 9.3.1 | Modules  | 293 | 
| 9.3.2 | Namespaces  | 296 | 
| 9.3.3 | Objects  | 300 | 
| 9.3.4 | Generic Implementations  | 313 | 
| 9.3.5 | Abstract Data Types  | 318 | 
| 9.3.6 | Libraries  | 319 | 
| 9.3.7 | Processes and Filters  | 323 | 
| 9.3.8 | Components  | 325 | 
| 9.3.9 | Data Repositories  | 325 | 
| 9.4 | Architecture Reuse  | 328 | 
| 9.4.1 | Frameworks  | 329 | 
| 9.4.2 | Code Wizards  | 330 | 
| 9.4.3 | Design Patterns  | 331 | 
| 9.4.4 | Domain-Specific Architectures  | 333 | 
 | Further Reading  | 337 | 
|   | 
| 10 | Code-Reading Tools  | 339 | 
| 10.1 | Regular Expressions  | 340 | 
| 10.2 | The Editor as a Code Browser  | 343 | 
| 10.3 | Code Searching with grep  | 346 | 
| 10.4 | Locating File Differences  | 355 | 
| 10.5 | Roll Your Own Tool  | 357 | 
| 10.6 | The Compiler as a Code-Reading Tool  | 360 | 
| 10.7 | Code Browsers and Beautifiers  | 365 | 
| 10.8 | Runtime Tools  | 370 | 
| 10.9 | Nonsoftware Tools  | 375 | 
 | Tool Availability and Further Reading  | 376 | 
|   | 
| 11 | A Complete Example  | 379 | 
| 11.1 | Overview  | 379 | 
| 11.2 | Attack Plan  | 380 | 
| 11.3 | Code Reuse  | 382 | 
| 11.4 | Testing and Debugging  | 388 | 
| 11.5 | Documentation  | 396 | 
| 11.6 | Observations  | 397 | 
 | Further Reading  | 21 | 
|   | 
| A | Outline of the Code Provided  | 399 | 
| B | Source Code Credits  | 403 | 
| C | Referenced Source Files  | 405 | 
|   | 
| D | Source Code Licenses  | 413 | 
| D.1 | ACE  | 413 | 
| D.2 | Apache  | 415 | 
| D.3 | ArgoUML  | 416 | 
| D.4 | DemoGL  | 416 | 
| D.5 | hsqldb  | 417 | 
| D.6 | NetBSD  | 418 | 
| D.7 | OpenCL  | 418 | 
| D.8 | Perl  | 419 | 
| D.9 | qtchat  | 422 | 
| D.10 | socket  | 422 | 
| D.11 | vcf  | 422 | 
| D.12 | X Window System  | 423 | 
|   | 
| E | Maxims for Reading Code  | 425 | 
 |  Bibliography    |  445 | 
 |  Index    |  459 (PDF 138K)  | 
 | Author Index   | 491 |