on March 9, 2004
I purchased the book to help me out with the recurring task of quickly understanding the nature of unfamiliar large software projects. Kudos to Mr. Spinellis for tackling this subject, which is a large part of the everyday work of programming.
Unfortunately, I feel that this book was of very limited use to me as an experienced programmer, and suffers from a rather basic flaw (as a topic). The problem is that the art of code reading is really the intersection of a deep and/or broad understanding of programming, in conjunction with a deep and/or broad understanding of the tools and practices employed. One could well assert that this book is about *debugging* unfamiliar codebases as much as it is about *reading* them, since code comprehension is a component of code debugging. This is a rather apt analogy, since many have attempted to describe the black art of debugging just as Mr. Spinellis has attempted with reading, and with no definitive "must-have" coverage to date.
The result is that I felt the book rushed through important programming concepts that were either extremely basic (global variables, while loops, conditionals, blocks), or language-specific (C typedef, arrays, function pointers), or too deep for the book to address adequately (trees, stacks, queues, hashes, graphs). With regard to the latter, I found it odd to be reading a lot of text about basic data structures, when it seemed to me that I should be assumed to already have this knowledge if I wanted to read code that used it. And if I did NOT know about basic data structures, I should be reading a book about data structures rather than a book about code reading. Software patterns are also presented (though not by the name, I think). If I was to encounter a codebase that employed some programming concept I didn't understand fully (for example, red-black trees), then I would first go to a book on data structures -- not a book on code reading.
Following the sections on what I would consider mandatory prerequisite understanding are some brief chapters software engineering concepts (version control, build systems, project organization, packaging, system structures), which might be useful to a reader who had never worked on a large-scale project before.
After all of the coverage of what I would consider prerequisite knowledge, the penultimate chapter finally gets to the topic of tools and techniques for actually reading code. This chapter is in fact what I had hoped Mr. Spinellis would devote the book to. Unfortunately, most of the tools and techniques presented are very basic and quickly encountered by any programmer: regular expressions, the fact that many editors include browsing support, the grep utility, differencing tools, the idea that you could write your own tools, using the compiler to emit warnings and preprocessed code, that beautifiers exist, profiling and annotating printouts. And that's it, in about forty pages, followed by a chapter devoted to an example session.
On the whole, I think this book comes up short. If you have a few years of programming experience under your belt, then you've already encountered the basic tools and techniques presented. If someone resorted to this book to learn about a basic programming construct, then they could read my code, but I'd be nervous about letting them modify it, until they read more focused texts.
I'm rating this book at three stars because there are some good pieces here and the effort was laudable. In the end, though, I really don't think that anybody needs this book on their shelf.
Programmers need to be able to look at code and analyze what it does in order to change it or fix it. The concept behind this book is to use many of the open source code samples to discuss how to read code and how to spot potential trouble areas in code. Unfortunately the book doesn't stay focused on this single goal and that detracts from its overall value. The book spends too much time explaining the basics of programming instead of concentrating on reading code. It also bounces around from one language to another, from C to C++ to Perl to Java, which is very confusing. For example, if you are a Java programmer do you really care how the C compiler optimizes strcmp calls? And what does that have to do with reading code?
Some of the advice is fairly basic such as try to realign indentations properly and replace complex code structures with simple placeholders when doing analysis. Although there are parts of the book that are excellent, too many of these good parts are wrapped under what should be basic concepts to anyone reading code. How can you debug a Java program, for example, if you are unfamiliar with abstract classes, libraries, or polymorphism? Do you really need a book on code reading to explain basic object oriented programming?
Overall, the book seems very unfocused and I really can't recommend it.
on August 29, 2003
This book is exactly what I was looking for to lead a seminar in bioinformatics at UNC Chapel Hill that brings together bio-chem-phys students with computer science students to try to raise the level of programming sophistication of the former, and raise the level of biochem/biophys sophistication of the latter. It collects examples of why and how to read code, pointing out lessons about the idioms and pitfalls that can help you write, maintain, or evolve code under your control. Full of good ideas, drawn from a lot of experience, and written with humor.
The only problem is that inexperienced programmers, who would benefit most from this book, are unlikely to pick up a book on how to read C programs unless someone tells them to. Experts will find that they have already learned most of these things from their experience, although they may still enjoy this book for confirming what they know. But I think that experts will also enjoy being able to loan this book to inexperienced programmers to transmit the wisdom distilled from experience.
on January 21, 2004
A valuable resource for best practices, do's and don'ts, what works and why, what you should do in various situations of project, code, and architecture evaluation, and everything in between. In one phrase, this book depicts Software Engineering's best practices for the real world. No heavy-duty processes to follow, no reading of Software Engineering text books that are over a 1000+ pages. More importantly, everything in this book is REAL. References are given to open source projects where the author took the examples from, and the CD-Rom includes the complete code examples given in the text.
The author starts off by giving a background on the most popular programming languages used in the open-source community such as C/C++ and Java. Some scripting languages such as a PHP and Perl are also covered, but the main focus of the book is on C and C++. Data types, data structures and control flow are covered respectively and various best practiced of "what to-do" is given for each topic. These topics are somewhat basic, and if you are an advanced programmer, you can read thru these chapters in an hour or so. Even though these chapters are basic, they contain valuable to-do's and best practices that everyone of us will surly benefit from. They style of the book and its structure is nothing like I have seen before and it takes a couple of chapter to get used to it.
Chapter 4 is one of my favorite chapters in this book. It talks about C Data Structures. Towards the end of the chapter, the author talks about Graphs and Trees. These two rather complex topics (books have been written on these two topics) are covered so well that with about 20 pages, the reader can get a very good understanding of the topics at hand. Concrete examples from various open-source projects are used again to get the point across, and the source code that is on the CD-Rom is reusable with little effort.
The fun begins with chapter 5, Advanced Control Flow. Recursion, exception handling, parallel programming and non-local jumps are the main topics covered in this section. Again, the sample codes really help the reader to understand the topic better, and they also can be refereed to in your next project - something I found very beneficial. Another interesting thing about this chapter is the part that compares the different thread implementation in various languages and platforms - Java, Win32 and POSIX. Example from each implementation is given to show the reader the difference in practices and to get the point across more clearly.
If you have ever been bored to death by reading books on Software Engineering and Software Processes and just wanted to be able to have a very light and proven process to help you out with your next project, then Chapter 6 - Tackling Large Projects, is for you. The author starts the chapter by going over some of the design and implementation techniques used widely in large projects such as:
· The need for a software process
· Complex Architecture
· The need to support multiple platforms
· The use of OO techniques
· Operator overloading techniques when appropriate
· The need for Libraries, Components and Processes
· The need for custom languages and tools
· The use of pre-processing for portability and other reasons
Some or all of these methods are needed in large software projects, and author goes into detail in chapter 6 to cover how these tasks can be accomplished efficiently and proactively throughout the project life cycle. The author starts by going over Project Organization such as directory structure and source tree organization to the build process to revision control for future releases and end the chapter with a topic on testing of software applications.
The next two chapters, Coding Standards and Documentation are simply priceless. In about 40 or so pages, the author is able to cram over twenty years of best practices in coding standards and documentation techniques. I have never read a book that covered these two topics so well. If you are a project lead, you can simply take these two chapters and use them in your next project because you will not find anything better elsewhere.
The biggest and the most imperative chapter in this book is Chapter 9, Architecture. Various architectural patterns are covered. Each pattern includes a list of projects in the open-source community where it was applied and was proven successful. The author then goes into various Control Models that are used in the industry such as:
· Event Driven Systems
· System Manager
· State Transition
And examples of each of these Control Models along with code samples are given. Various packaging methods and schemes such as namespaces, modules, objects, generic programming, Abstract Data Types and libraries are also depicted in this chapter. Chapter 9 is the longest chapter in this book, but also the most informative one.
D. Spinellis did a great job putting this book together. This book is packed with examples, best practices and information that are useful to developers, project leads and managers. Now you can have all the experience of the open-source community, the people that developed Linux, Apache and other popular software applications, at the tip of your finger.
If you're a programmer, you are going to be reading the code that others write. It's as simple as that. But reading code is not like reading someone's novel or article. You have to figure out what the code is doing, what was the intent of the writer, how does the code fit with all the other pieces, etc. Often, all that needs to be done without a single comment, either. With that in mind, Diomidis Spinellis wrote the book Code Reading - The Open Source Perspective. There are some pretty good perspectives and techniques here that probably work best if you're familiar with C and Unix...
Contents: Introduction; Basic Programming Elements; Advanced C Data Types; C Data Types; Advanced Control Flow; Tackling Large Projects; Coding Standards and Conventions; Documentation; Architecture; Code-Reading Tools; A Complete Example; Outline Of The Code Provided; Source Code Credits; Referenced Source Files; Source Code Licences; Maxims for Reading Code; Bibliography; Index; Author Index
Some of the material is universal regardless of your platform of choice... why it's important to be able to read code, how basic program flow determines the "narrative" of the program, etc. He uses little icons in the side bar (an "i" and an exclamation point) to point out common programming idioms as well as dangerous techniques that might not work as first expected. On the flip side, a lot of the examples use C or C++ code to demonstrate some example that may only be of interest to you if you use those languages. Diving into malloc and the intricacies thereof might allow you to understand some concepts, but it might be a bit difficult to extract out the applicable material if you're not using the C family of languages. Likewise, using Perl or grep to examine source code is great if you know Perl or grep, but you may be tempted to skim large portions of those chapters if those are not your skill sets...
So would I recommend the book? Probably... but your impression of the book will likely depend on how close you match the skill sets talked about and used in the book. Even if you don't qualify as a Unix geek, you can still get value here... you'll just have to work a bit harder...
on July 21, 2003
Those wishing to understand the various styles of programming and meta-programming that have become common in open source code, as well as those who seek to broaden (if not deepen) their understanding of software engineering, would be smart to pick this up. Not only will this book help you to understand the innards of your favorite or least favorite software, but it provides insight into why the creators made the choices they did. It's not going to teach you about computer science as well as a good textbook will, but it will give you an understanding of and appreciation for what programmers balance in their minds as they shape their complex creations. Think of it as The Story and its Writer (ISBN 0312397291) applied to software.
on June 22, 2003
This is the most interesting technical read I have had since the release of Dave Thomas and Andrew Hunt's "Pragmatic Programmer". Which isn't suprising, given that Dave appears to have been involved with this book as well.
The conveys book experience as opposed to raw information. He gives pragmatic advice that will benefit both junior and senior engineers in their day-to-day code and project development.
I've become bored with the usually 'foo in three weeks' style books. If you are in the same position and you are interested in books about proven techniques and the pragmatic approach, this book is for you.
The first few chapters had me questioning my purchase but the closing chapters removed any doubt that I had spent my money well. There were helpful hints that will save me minutes and hours throughout the work-week which means that I will be working smarter rather than harder.
It was only through random chance that I saw this book in the Palo Alto Borders. Great books like these need solid marketing. That being said, I applaud Addison-Wesley in their investment in a book like this which is a little outside of the norm, but is an incredibly valuable work for the software engineering community.
on November 4, 2003
Why do people approach the same problem in many ways?
There is no ONE answer to it. The Code Reading is not an easy subject by any means. I do not know of any other book that even tried to attempt at this subject. So, I picked this one with out even thinking twice.
The first reaction when I read the book is "what the he... is this all about" :-). I guess, it is the same reaction I had got many times reading and understanding code written by others.
Just as in it takes a while to understand and digest a piece of new code you ever come across, it might take a while to get to understand and digest the concepts behind this book. I had to revisit and reread the concepts and apply it to practical situation to be able to grasp the abstractness of the subject in a concrete manner :-).
If you are with me this far, probably this book is for you. Still wondering what the heck is all this about? Here is a simple explanation from myside:
If you LOVE to do coding, HAVE to read the code for a living, WANT to learn *any* TECHNIQUES, then this book is for you!!!
on October 17, 2005
I agree with the two previous reviewers (Paul and Hollasch). On the positive side, the author's obviously a serious scholar. His knowledge is broad and on some subjects deep as well. The bibliography is extensive and offers good leads for further reading. However, he attempted to do too much in a single volume. The book title is "Code Reading," but the author covers everything from architecture to revision control to configuration management to documentation, with none detailed enough to be useful. Most code examples covered are in C, but he also sprinkled the book with Java, Perl, and even makefile codes. Take that makefile code as an example, if you are not familiar with makefile, you are bound to be lost in his detailed explanation of the code. On the other hand, if you already know makefile and regularly write or modify one, the explanation is isolated and gratuitous, because if necessary you would rather consult a reference book devoted to that subject. Another drawback is that the author spent too many pages stating the plain obvious, effectively drawning the few unique good points of his own. I also noticed that the author presented outdated or not-so-modern materials. For example, he mixes C with C++ and makes incorrect claims no longer applying to both. (It appears to me that the author had no idea about post-98, modern C++.) Another example is Hungarian notations, which has been discounted by Microsoft, with the advent of C# and their fancy new visual IDE tools.
on March 16, 2005
I run a small programming contest over the Internet (Ruby Quiz), so the author of Code Reading: The Open Source Perspective and I share a passion. That's exactly what Code Reading is all about. If you often read the code of others, because you enjoy it or because you are required too, this book contains a lot of tips you probably don't want to miss.
Code Reading is collection of hints and tips for anyone examining the code of other programmers. It covers common code idioms, strategies for understanding large software projects, design patterns of common system architectures, how to approach documentation and even style guidelines, useful tools for divining the inner meaning of code, and more. The book presents tactics for the code reader with solid prose and plenty of examples. There's also a nice appendix summing up the author's message point by point.
I need to tell you a lot more about those examples I mentioned. The number one complaint about programming books is their often trivial examples that lack depth and would never be encountered in the real world. That complaint will never be leveled at this book by anyone. The author chose to showcase well-known open source code for all the examples in his book. A small sampling of the projects used include the hsqldb Java database, the Apache and Tomcat Web servers, the Perl programming language, and the NetBSD Unix distribution. You heard that right, he pulls examples out of an operating system. It can't get much more real-world than that.
The techniques of the book are all encompassing, as far as languages go. However, the majority of the book's examples are in C. C is the most common language used in open source software (according to the book) and it's a good common ground for many of us programmers, so the choice fits. The first three chapters dig into common C coding constructs and data structures. That was nice for guys like me that haven't played with C in a while and just need a little refresher course. However, if you don't have at least some grasp of C going in, this book would probably prove challenging to follow.
I'm going to give it to you straight: Code Reading isn't easy. If your looking for a bathroom reader you can coast through, this isn't it. The examples are real and the ideas behind them can get complicated. Each subsection of the book ends with some suggested exercises you can try out, to help the book's wisdom sink in. Many of these are non-trivial and require some effort on the part of the reader. However, they are very rewarding to those willing to apply themselves and you can almost feel yourself getting smarter as you work through them. You will get out of this volume what you put into it, in other words.
The book comes with a CD of open source projects. It claims there are seven million lines of data and code and I believe it. The CD includes the projects I mentioned above and more. This is where the book's examples come from and it's a terrific resource for practicing the suggested exercises. This was a very nice touch.
The book does try to focus on good code for reading, but it's realistic enough to know that you can't always get that. The author even shows some examples where his expectations worked against him, and talks you through his own process of getting to the truth. An extended example in the final chapter of the book showcases this well. The author pulls an algorithm from an operating system, to embed it in a database written in a different language. This is a real-world task and you get to watch him run into some real-world problems which he must troubleshoot. The rest of the text is even thoughtful enough to point out when you should become suspicious of the code you're examining. I appreciated the focus on what we actually see in the wild, verses what we would like to see.
The book's layout is generally fine, but I do have one complaint. Some code examples are inline with the text while others are pulled out into figures. In a couple of places, the figures can become quite small. Also, because figures appear in the normal flow of content, you occasionally see an inline code example split by an unrelated code figure. These issues were not frequent, but they where annoying when encountered.
If you're a programmer, odds are you have to read code written by other programmers fairly often. Some of us even do it for fun. Regardless of the whys, Code Reading can make you better at it. I believe that makes me a better programmer and thus is well worth the effort.