Slashdot Mirror


Practical C++ Programming, Second Edition

adrienlamothe writes "Practical C++ Programming is dedicated to teaching the reader how to program in the C++ programming language. The book actually has four goals: 1) Teach the reader C++. 2) Instill good programming style and practice (indeed, the book's subtitle is 'Programming Style Guidelines.') 3) Teach the programmer basic software development concepts. 4) Introduce the reader to debuggers and the make utility. 4) The author encourages the reader to use a computer to enter, run and debug the book's programming examples. I concur with this advice, though it isn't absolutely necessary." To see how well the book meets its own goals, read on for the rest of Lamothe's review. Practical C++ Programming, Second Edition author Steve Oulline pages 549 publisher O'Reilly & Associates rating 7 reviewer Adrien Lamothe ISBN 0596004192 summary Guide to learning C++ and programming style.

Practical C++ Programming is a fairly large book: 549 pages organized into six parts containing 30 chapters and 5 appendixes. The parts are as follows:

  1. The Basics
  2. Simple Programming
  3. Advanced Types and Classes
  4. Advanced Programming Concepts
  5. Other Language Features
  6. Appendixes.
You will have to read most of the book in order to learn C++, although there are a number of chapters you can avoid if your goal is to learn only the language's mechanics.

I must start by saying that I like the book -- I think it has value. There are a number of things I really appreciate about the book. There are also some problems that adversely impact one segment of the book's intended audience (more about those later.)

The book discusses all the essential elements of C++. Areas covered include: Class definition, namespaces, scope definition and resolution, operator and function overloading, object memory allocation (i.e. new and delete,) type casting, exceptions, inheritance, templates (including an introduction to the Standard Template Library,) the Input/Output system (including the C I/O library), and pointers. All language operators are discussed (i.e. relational, assignment, etc.) Also covered are language elements that C++ has in common with C. The other areas of instruction (programming style, software development concepts, programming tools) are intertwined with the primary topic throughout the course of the book.

One of the book's strong points is the author's excellent conversational writing style. It's hard to find books that combine good technical information with clear expository writing (O'Reilly seems to publish most of them.) Practical C++ Programming definitely succeeds in this area. The author frequently references his own experience to reinforce concepts on programming style, design and debugging. I found his anecdotes useful and occasionally humorous. The book also contains small sections of text that serve to warn the reader of pitfalls (these are marked with a bear trap icon) and areas where caution should be exercised (marked with bear paw tracks). Also, some of the source code examples contain intentional bugs, which the author explains at the end of each chapter. Diagrams, tables and source code examples are found on almost every page of the book, and these are used to keep the reader engaged with the textual discourse. My favorite diagram is Figure 7-1. "Software life cycle," on page 88; I emphasize with the dinosaur.

The book contains some interesting programming examples. The chapters on operator overloading and floating-point math contain source code illustrating how to deal with the numeric precision problems that plague all computers and computer languages. The chapter on the Standard Template Library contains a program showing how to create and use objects that manage a simple roster for enrollment and grading of students. The book also contains several examples of linked-lists and trees, for the purpose of teaching the reader how to use pointers, and to also show the reader the power and usefulness of the Standard Template Library.

Now to speak about the book's shortcomings. First, although the book does a good job of covering the important C++ topics of classes, inheritance, and templates, I think it falls a bit short in these areas (especially the coverage of inheritance). Also, the terms instantiation, polymorphism and encapsulation are not used in the book. The book could have provided a bit more insight into object-oriented concepts. Also, these areas of the book are sparsely diagrammed. Second, source code errors and typos appear regularly enough to frustrate an inexperienced reader. I also found a couple of diagrams to be confusing. Third, there are occasional misleading statements that a beginner probably won't recognize as such. Because of these problems, I cannot recommend the book to people with no previous programming experience. I'm surprised that these problems made it into a second edition.

I think that despite these problems, the book has value to experienced programmers who want to learn C++. C programmers in particular will have an easier time dealing with the source code errors. Also, I think that the book can be used by beginning programmers in a classroom environment, providing the instructor understands the book's problems and is prepared to guide students around them. The book should be particularly useful when read in conjunction with a good C++ reference guide.

Practical C++ Programming is an ambitious work in its breadth and depth. It covers more areas of software development than other C++ books. It takes an interesting approach that some readers will appreciate and others may not.

I would like to have seen a more detailed and complete explanation of the object-oriented aspects of C++ (including more diagrams). A table showing all functions for Standard Template Library containers would have been nice (the book does make reference to two STL web sites). Some mention of third-party object libraries (such as Rogue Wave, Qt, etc.) and their uses would have been helpful.

The lack of a detailed explanation of inheritance may not be bad. I'm one of those who believe that heavy reliance on inheritance causes serious maintainability problems. However, I think the book should have covered this topic more fully, so the reader would understand this issue.

In summary, Practical C++ Programming is a good book that really shines in some aspects and falls short in others. With some improvement, it could be a great book.

You can purchase Practical C++ Programming, Second Edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

14 of 266 comments (clear)

  1. $4 less and free shipping at amazon! by Anonymous Coward · · Score: 3, Informative
  2. Teaching the user C++... by devphil · · Score: 5, Informative


    ...should, I have decided, always involve the text Accelerated C++, by Koenig and Moo. They have been working with C++ since its inception, down the hall from Stroustrup.

    The book takes two relatively new approaches to teaching C++: 1) don't teach C first, and 2) assume that the standard C++ library is there. So, they introduce "Hello, World" using std::string and std::cout, and they keep using std::string without trying to first teach template classes with default template parameters. The resulting intro programs are very clean and simple, easy to follow.

    The word "pointer" isn't even mentioned until chapter 9. By that point, they're using strings and vectors to solve useful programs, and since both of those containers manage memory themselves, the user needs to know nothing about dynamic memory management (and thus, pointers) before doing the exercises.

    Pointers and user-defined types are introduced, of course, but they don't need to be introduced before showing the reader how to use the basic library features. You don't need to know how an internal combustion engine works before learning how to drive, although going back later and learning what's under the hood will always reward the observant driver.

    This approach has gotten rave reviews, and from actual C++ people, not just fluff reviewers. It's the produce of years of teaching C++ courses.

    Final note: the book is one of the fantastic "C++ In-Depth" series, of which Stroustrup is the series editor. All are very high quality. One of the series' rules is that the main body of the book can be no more than 300 pages, so "make your point, make it simple, make it clear" rules the day.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  3. free on safari.oreilly.com by asv108 · · Score: 3, Informative

    Why buy the book when you read it on safari, along with thousands of other books with a free 14 day trial..

  4. 1st Edition Lacked by 4of12 · · Score: 4, Informative

    The author did a very nice job on Practical C Programming.

    But Steve O. shouldn't have let himself be conned into writing the Practical C++ Programming, though. His C bias weighs too heavily and the first edition spent all kinds of time talking about wonderful linked lists with structs just like the C book did.

    If you want to learn C++, my suggestions are:

    • C++ Distilled by Pohl
    • Effective C++ by Scott Meyers
    • More Effective C++ by Scott Meyers
    • The C++ Standard Library by Josuttis
    some other are also good, and of course no guru should be without one of Stroustrup's tomes.
    --
    "Provided by the management for your protection."
  5. The first edition ... by Chromodromic · · Score: 5, Informative

    ... is reviewed here, at the 'net's largest C++-oriented book review site. This review is decidedly in the negative, although Steve Oualline is given a chance to issue a response which is worth reading.

    It seems that the 2nd edition of this book may have brought forward some previous problems. I have the first edition but never liked it, never thought it really achieved it's goals.

    If you're looking for an uncompromisingly amazing first book on C++, please check out Accelerated C++ by Andrew Koenig and Barbara Moo. This is how I learned C++ and, by using the concepts of teaching core language skills alongside library concepts and best practices in OOP, it truly accelerates the process. Amazing.

    --
    Chr0m0Dr0m!C
  6. OO Features of C++ by mofochickamo · · Score: 2, Informative
    I would like to have seen a more detailed and complete explanation of the object-oriented aspects of C++ (including more diagrams).

    Also, the terms instantiation, polymorphism and encapsulation are not used in the book.

    Seem odd to me that a book that is designed to teach C++ would skimp on the object oriented features of C++. I find polymorphism extremely powerful in many situations. For example, I use it often with bison when writing parsers, and for writing cool Zoo example programs where you call a function MakeSound and it automatically says "Ooo Ooo" for the Monkey, and "Eeeee haaaaa" for the Ass.

    --
    Honk if you're horny.
  7. Reference Card by nycsubway · · Score: 3, Informative

    I also recommend a reference card to help people learn C++. When programming in a new language, it is helpful to be able to look up syntax quickly.

    This is a plug for the card, but you can download a PDF of the card for free.

  8. Re:Debugging by cK-Gunslinger · · Score: 2, Informative

    It's not always a memory error. On fast, multi-threaded apps, it is sometimes timing related. That little bit of time it takes to dump some text out to console is often just enough to mask any synchronization problems.

  9. What's Cheaper & Where (why just B&N and A by TastyWords · · Score: 3, Informative

    Instead of comparing just B&N vs. Amazon all of the time, why not use the book shopping bots? (Amazon and B&N are not the cheapest books every time you buy a book (they may be in this case (I checked), but in many cases, the others are much cheaper)! The bots search a lot of the book stores and rank the prices (including handling/shipping), present opportunities for discounts, and even point out the ability for finding books which may be out of print but can be purchased used.
    Think of this as a book equivalent to PriceWatch

    (these links were tested in 'preview' mode before posting.

    BookPool
    AddAll
    BestBookBuys

  10. Re:Offtopic by datan · · Score: 2, Informative

    visual studio's IDE (well if you're a purist you can not use the visual part of VC++) allows you to debug your functions and watch your memory allocation [stack/heap] and registers as you step through. I think this is what you want.

  11. Speaking of the book's rating on amazon by snooo53 · · Score: 2, Informative
    Anyone else notice that the customer reviews are 2 out of 5 stars? Not terribly impressive. I tend to look very closely at the customer reviews for before buying something, and I'd immediatly flag anything that had this few reviewers and such a low rating, be it a book, movie or hardware.

    I think in this case, I'd just head on down to the library and flip through their C++ books until I found one I liked. Or grab a copy of Deitel & Deitel since that seems to be a pretty standard introductory textbook for programming classes.

    --
    The sending of this message pretty much inconveniences everyone involved.
  12. Re:I don't usually bitch about slashdot "reviews" by Anonymous Coward · · Score: 1, Informative
  13. Review critique, book critique by stew1 · · Score: 2, Informative

    Some problems with this review:

    1. Where's the basic information about this book? Author, publisher, ISBN, list price, etc. None of these are mentioned in the review (yes, there's a link to B&N, but, c'mon).

    2. Sequencing is an essential aspect of a technical book review. In what order does the author address the topics? Are there many forward references? Does the author march through the topics one at a time or is the subject matter gradually explored, step-wise? A Table of Contents listing (instead of the simplistic 6 parts) would be nice, at a minimum.

    Some problems with this book:

    1. Having found the TOC on O'Reilly's website (http://www.oreilly.com/catalog/cplus2/toc.html), it's clear that this book features the Bad Old Style of C++ pedagogy: namely, teach C first. The author tackles arrays before std::vector, structs (and unions!) before classes, C-style linked lists before std::list, switch statements before virtual functions, and macros before templates. The new approach to teaching C++ is to give the user familiarity with the powerful utilities of the standard library, so that useful programs can be written right off the bat, and then to explore the dizzying array of language constructs which make the standard library what it is. I encourage those new to C++ to check out Accelerated C++ as an alternative introduction to C++.

    2. The reviewer points out that there are many code errors in the book. This is unacceptable, especially for a beginning book. A small number of obvious typos can be forgiven, but anything more than that should consign a tech book -- again, especially an introductory book, where the audience has little experience for dealing with errors -- to the circular file.

    While I love many of O'Reilly's offerings, their coverage of C++ has always seemed spotty and outdated. I encourage anyone trying to learn C++ to check out the C++ In Depth series published by Addison-Wesley, starting with Accelerated C++ and Essential C++.

    Jon

  14. Misinformation card [Was: Re:Reference Card] by jdennett · · Score: 2, Informative

    void main? No points.

    ? Not part of Standard C++, which has instead.

    The rest of the card doesn't look much better. The reserved words are listed and the card notes that they can't be used as identifiers, but it doesn't mention that there are other reserved identifiers.

    The description of while(x) says that x must be an expression, but for a long long time C++ has allowed a variable declaration at this point, and such use is idiomatic.

    The example of operator overloading is far from ideal: the argument is idiomatically passed by const reference, not by value, and for operator- it's normal to copy and then subtract the rhs, rather than the more C-inspired code shown.

    This card might be helpful in its free version, but if you pay money you probably want something that's teaching correct/good C++.

    Maybe with an update the card would be a good thing. Visually it's not unappealing and some thought has clearly gone into it: it's just that it has not been written by a C++ expert.