thraxil.org:

Grr, I say! Grr!

by Mark Boudreau Sat 08 Feb 2003 01:10:22

Have you ever tried writing a application or a class from a book? I was writing a SMTP Mail Class in php from a pretty decent Wrox book (Professional PHP4). Everything was straight forward and I was getting a good lesson in object oriented coding. However, the code was wrong in a number of ways (functions misnamed, processes insufficient). Not to mention the fact that the code that the book provides for download was wrong in ways completely different than the code as it was written in the book. Have anyone else had this kind of trouble with books on Programming? You'd think they would at least run the code before they publish it. On the bright side of things, debugging this class taught me a lot more about socket programming and SMTP calls than I would have known before. *shrug*
TAGS: programming php frustration

comments

that's pretty disappointing for a WROX book. they're usually good stuff. is there a website with errata for it? if they don't have an errata site, that is unforgiveable. it must be hard though to write a tech book and not have bugs in the code. the code probably evolves in the same way real code does, except since it's just in a manuscript there is even less incentive to actually test it out and testing becomes more difficult than it would be for normal code. i remember <a href="http://www.bruceeckel.com/">Bruce Eckel</a> writing about an automated system he'd developed for his books that would go through and extract all the code samples and test them. it can get pretty tricky if you think about it. especially for a language like java where the class name has to match the filename. if you have a chapter that introduces class Foo and then points out some problems in it and shows an improved version of class Foo. now you have two different pieces of code that both want to be in a file named 'Foo.java'. the other tricky situation is small code snippets that aren't really complete enough to run on their own. for those you need to include a mechanism for including the snippet itself and some framework code that is needed for testing but won't get displayed in the book. with everything that would be involved in regression testing code examples, i'm not surprised that most authors don't bother. i guess one strategy would be to copy Don Knuth and only publish the book after a decade or two of careful editting and include a rigorous proof of the correctness of each piece of code...
Wrox does have errata up for the book, but it doesn't mention a lot of what I've come across so far. It's still a great book, and I have learned a lot from it, but it's still can get frustrating when the debugging doesn't go well (and until I had a eureka type revelation, it was going quite poorly). I suppose I could submit some of the errata I've found, but that would take a bit of time that I don't really have.

formatting is with Textile syntax. Comments are not displayed until they are approved by a moderator. Moderators will not approve unless the comment contributes value to the discussion.

namerequired
emailrequired
url
remember info?