You've got a day to add a new feature in a 34,000-line program: where do you start? How can you understand and simplify an inscrutable piece of code? Where do you start when disentangling a complicated build process? How do you comprehend code that appears to be doing five things in parallel? You may read code because you have to, to fix it, inspect it, or improve it. You may read code the way an engineer examines a machine, to discover what makes it tick. Or you may read code because you are scavenging, looking for material to reuse. Code-reading requires its own set of skills, and the ability to determine which technique you use when is crucial. In this book, Diomidis Spinellis uses more than 600 real-world examples to show you how to identify good (and bad) code: how to read it, what to look for, and how to use this knowledge to improve your own code.
Fact: If you make a habit of reading good code, you will write better code yourself.
Review By: Gerald Thompson, Perforce Software 03/04/2005Thanks to the availability of open-source software, programmers who have access to the Internet have an opportunity to find high quality examples of source code. In "Code Reading: The Open-Source Perspective" the author, Diomidis Spinellis, asserts that in order to write good code, programmers must read vast amounts of code and learn from software written for a variety of different purposes. Just as a good novelist is typically an avid reader, a good programmer should be an experienced source code reader. The author uses real examples from the body of code available in the open-source community to aid readers in developing a code reading strategy. Code snippets are annotated clearly and referenced for further reader analysis.
A companion CD complements the code analyzed in the book with source code trees of the program examples. A large amount of open-source code is written in C and the book uses C language examples for most discussion sections. Java programming language examples are also included. The author guides the reader through analysis of basic programming elements, advanced data types, data structures, and advanced flow control. Methods are suggested for tackling large projects, taking advantage of coding standards and conventions, using documentation, and evaluating architecture considerations when developing expertise in reading code. The author uses very clear and concise language to guide the reader toward best practices in reading code. Each section includes exercises, but no suggested answers are provided. The author encourages readers to learn from the open source examples freely available and repay the open-source community by submitting code to the body of open-source software.
"Code Reading" is a valuable tool for Quality Engineering professionals who wish to gain expertise in reading source code. The author maintains that in order to write good code, programmers must read a large amount of source code written for a variety of purposes. QA engineers may also be required to read and understand software code in order to provide suggestions for improvement in design, style, or process considerations. Developing a strategy in reading code is essential when attempting to read large bodies of code. The author uses real source code examples in C and Java programming languages that are available as open-source. The reader is guided though methods to read and understand basic programming elements, advanced C data types, C data structures, and advanced control flow. Code snippets are clearly annotated, with references to source code trees of software examples illustrated in the book contained in a companion CD.
The author aids readers in developing a strategy for tackling large projects, using and enforcing coding standards and conventions, using documentation, and evaluating and appreciating architectural considerations. The author includes maxims for reading code that are sprinkled throughout the book to motivate software developers to actively create a comprehensive code reading strategy.