code reading dds

Code ReadingTable of Contents

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

Book homepage | Author homepage


Valid XHTML 1.0! Level Triple-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0 (C) Copyright 2000-2003 D. Spinellis. May be freely uploaded by WWW viewers and similar programs. All other rights reserved.
Last modified: 2003.06.12