Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Practical C++ design : from programming to architecture
Singer A., Apress, New York, NY, 2017. 246 pp. Type: Book (978-1-484230-56-5)
Date Reviewed: Feb 1 2019

Not long before reviewing this book, I taught a class in C++ using Bjarne Stroustrup’s book Programming: principles and practices using C++ [1]. In four chapters (out of 26), Stroustrup has the reader build a small calculator, including several advanced features. I thought Practical C++ design would be a great follow-up since its focus is on building a calculator in C++, and I would surely pick up ways to extend the calculator I had built. But to my surprise, Singer takes a whole book to design a calculator that is in several ways less fully realized than Stroustrup’s, for instance, there are no variables and no grammar-driven parser.

To be fair to Singer, he does include features Stroustrup does not, such as a complete separation of his calculator engine from the user interface, which enables him to create a two-faced calculator that can appear on the command line or in a graphical user interface (GUI). And he shows how to implement a plug-in feature to extend the calculator, also absent in Stroustrup’s program. Furthermore, Singer does an excellent job explaining the design patterns he employs to create each of his calculator’s features.

The book begins by setting out the “requirements” for the calculator to be built. Even on a small project like this one, explicitly stating what is required may be useful. And here, this serves an additional didactic purpose. However, one of the requirements of the project is that the calculator use reverse Polish notation (RPN). Singer assures us that if we just get used to RPN, we’ll like it. But several hundred years of mathematical practice suggest that human beings most easily understand mathematical expressions when they are written in the “normal” way, that is, using infix notation. RPN was created to ease the burden on programmers and machines, not on users.

After laying out the user requirements, Singer explains his design requirements. The difference between the two is that the user requirements delineate what the software ought to do, while the design requirements describe how it ought to be constructed, in order to do what it needs to do. The chief design virtues Singer wants to illustrate are modularity, encapsulation, cohesion, and low coupling.

Singer next explains the idea of patterns and differentiates (software) architectural patterns and design patterns. Per his distinction, design patterns apply primarily to a class or a small group of classes, while architectural patterns address entire information processing systems.

The first of the two architectural patterns that Singer examines is multi-tiering, separating a top-tier user interface from a middle logic tier, and a bottom-level data tier. The second is model-view-controller (MVC). Singer describes the major difference between them: the multitier pattern restricts communication in the system to adjacent tiers, while the MVC pattern allows each of M, V, and C to communicate with the others as needed. (Singer winds up choosing MVC for his application.)

In the rest of his progress toward a working calculator, Singer addresses many more important design ideas, including the pimpl idiom (a private pointer that keeps a class’s private implementation out of a header file), the observer pattern (for waiting on events), and the command pattern (for implementing commands like add and subtract). He discusses modern C++ features such as unique and shared pointers, the “final” keyword, and uniform initialization, and shows how they are superior to older styles used in similar situations.

Due to Singer’s attention to modular design and his wise use of design patterns, the main() function of the calculator can set up, assemble, and execute the calculator in just six lines. As he notes, the most important aspect of such a design is that a new programmer coming along to maintain the program can easily grasp its overall structure.

This excellent book clearly demonstrates how to employ many object-oriented programming (OOP) design patterns to create a maintainable, working program. I only wish Singer had taken note of his illustrious predecessor’s work in the same domain, as he could have shown us how to extend Stroustrup’s calculator instead of starting over and thus omitting key features.

Reviewer:  Eugene Callahan Review #: CR146410 (1904-0087)
1) Stroustrup, B. Programming: principles and practice using C++ (2nd ed.). Pearson, Upper Saddle River, NJ, 2014.
Bookmark and Share
  Reviewer Selected
Featured Reviewer
 
 
Object-Oriented Programming (D.1.5 )
 
 
C++ (D.3.2 ... )
 
 
Reference (A.2 )
 
Would you recommend this review?
yes
no
Other reviews under "Object-Oriented Programming": Date
Object-oriented programming systems, languages, and applications
Paepcke A.  Object-oriented programming systems, languages, and applications,Phoenix, AZ,Oct 6-Oct 11, 1991,1991. Type: Whole Proceedings
Oct 1 1992
Object lifecycles
Shlaer S., Mellor S., Yourdon Press, Upper Saddle River, NJ, 1992. Type: Book (9780136299400)
Apr 1 1993
Object-oriented programming
Voss G., Osborne/McGraw-Hill, Berkeley, CA, 1991. Type: Book (9780078816826)
Oct 1 1992
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy