When I review a book I try to take into account the declared purpose and intended readership. The author of this book firmly states that his intended readership is those taking their first computer science module (semester, CS1) and that his intention is to use C++ programming as a tool for introducing the subject. He nails his colours to the mast with a declaration (supported by quotations from such experts as Professor Hoare and John Guttag) that computer science is ultimately about the art of computer programming.
He has a highly readable style and introduces a wide range of peripheral topics through frequent sidebars. He has clearly done his research and the result is a book that could act as an excellent basis for a computer science course. Quite sensibly the author makes it clear that this is not primarily a book about C++. However he does set out to introduce C++ soundly so that it can be used correctly in subsequent modules (semesters) of computer science. Generally the author does an excellent job in achieving his objectives and there are many courses that would be greatly improved by using this book.
The author encourages students to understand design and implementation by focusing on adapting and correcting code examples. The task of writing code from scratch is daunting to many and there is much to be said for learning by modification. To be as effective as possible the code provided must be of exemplary standard (except for the deliberate error).
Despite my over all positive feeling about this book I would not be doing my job as a reviewer if I failed to highlight a few flaws and issue a couple of caveats.
The first problem is a combination of the time when the text was being developed coupled with the limitations placed on many universities. Despite the copyright date of 1998, the main development of the text took place in 1993-4 so it is based on a version of C++ that is largely that described by Bjarne Stroustrup in the second edition of The C++ Programming Language (Second Edition) and supported by compilers at that date. The author restricts himself to the highest common factor of available compilers (necessary with student budgets being very tight) and so you will not find all the more recent features of C++ (the author does use templates - that ensures you cannot use a Microsoft 16-bit C++ compiler. but there are no exceptions, namespaces or use of STL etc.) that, in my opinion, greatly enhance the usability of C++ at all levels. Unfortunately the move from the versions of C++ used by this book to those that exemplify best modern practice is far from simple. Bjarne Stroustrup found it necessary to entirely rewrite and reorganise The C++ Programming Language 3rd ed for the 3rd edition, I think a similar effort will be necessary to produce the next edition of this book. That will need to be done soon. The consolation is that C++ is now stable and best practice is reasonably established by the handful of true experts (rather than self declared gurus).
The author's C++ class design is better than many but I think that his code would have benefited from a thorough review by a specialist in class design and implementation. Carrying out my usual checks on code quality I took a long look at the author's design and implementation of a big integer type. The implementation is only available via the Internet.
I was delighted to see that the author declared a
However the author blotted his copybook by declaring
operator< ()as friends. To my mind the correct mechanism is to provide
compare()as a member function and use that to provide the operator functions (globally because they need either operand to be promotable from a built-in integer type.
I then looked at his implementation for
operator=(const BigInt&). Fine, not the latest idiom but perfectly satisfactory. Actually the implementation does not need a user defined
operator=(const BigInt&)because the compiler generated version will work happily. It would have been useful to have provided an overload to provide
Next I looked at the implementation of
operator -=()and was very disappointed. The code is overly complicated and in one case results in an indirect recursive call (via a call to
operator-()) to itself. The problem is that the author has designed BigInt to be sign and magnitude with the magnitude held in a
vector(his implementation not the STL one). This means that half the time the magnitude data for the two operands needs to be reversed. I think the correct solution is a pair of helper functions, one to subtract magnitudes and one to add them which can be called as required by the
operator -=()functions. This would lead to a much cleaner design. If you coupled this with a call to a conventional compare() function the case of zero answers would be handled at virtually no cost.
The principles and overall plan of this book are excellent but the author really needs to find an expert C++ practitioner to provide exemplary (rather than generally good) designs and implementations to complement his expertise as an educator.
The author replies:Thanks for the opportunity to respond to your review.
In general I agree with your views and comments. In particular, the BigInt class that you properly critique was changed substantially as my understanding of design increased from the time I started (as you point out, 1993) and now. In particular I wrote a case study for the Advanced Placement exam in Computer Science based on a revised version of the class:
http://cbweb1.collegeboard.org/ap/computer-science/html/code001.html(Advanced Placement is a program whereby students earn college credit for courses taken in high school).
In the newest version there are no friend functions at all. The design would still benefit from the helper functions you mention for dealing with addition and subtraction - I'll do this in the next edition of the book, which I'm working on now. - Owen Astrachan.I have published the response from the author because it highlights the difference between good authors and self-proclaimed gurus. This author wants to improve, that makes his work worth watching. - Francis Glassborow