Preface (5 pages)
The preface details my motivation for writing the book, the target audience for the book, the
general structure of the book, and how to contact the author. Of particular importance is the
rationale behind choosing the case study, the target language (C++), and the GUI toolkit (Qt).
Chapter 1: Defining the Case Study (6 pages)
The first chapter describes, in detail, the case study to be examine in the book. The chapter
discusses requirements in the abstract and then transitions to the calculator’s specific requirements.
This sets the stage for the remainder of the book, which describes, in detail, the design and
implementation of the calculator, pdCalc, proposed in Chapter 1.
1. A Brief Introduction
2. A Few Words About Requirements
3. Reverse Polish Notation (RPN)
4. The Calculator’s Requirements
5. The Source Code
1The advic
e, information, and conclusions discussed in this book are those of the author and have not been
endorsed by, or reflect the opinions or practices of, ExxonMobil Corporation or its affiliates.
5
Chapter 2: Decomposition (18 pages)
In this chapter, I explain the elements of a good decomposition and strategies for decomposing a
problem into manageable pieces. Subsequently, an architecture for pdCalc is selected, the calculator
is modularized, and use cases are used to develop interfaces for the high level calculator modules.
The four high level modules are the stack, the command dispatcher, the user interface (subdivided
into a command line interface and a graphic user interface), and a plugin manager.
1. The Elements of a Good Decomposition
2. Selecting An Architecture
3. Interfaces
4. Assessment of Our Current Design
5. Next Steps
Chapter 3: The St
ack (20 pages)
The stack is the first module discussed in detail. The stack is the fundamental data repository
of the calculator. As part of the calculator’s design and implementation, the singleton pattern is
explored. The stack also affords the first opportunity to discuss an event system for the calculator,
which provides a backdrop for exploration of the observer pattern, including the design and
implementation of reusable publisher and observer abstract classes.
1. Decomposition of the Stack Module
2. The Stack Class
3. Adding Events
4. A Quick Note on Testing
Chapter 4: The Command Dispatcher (32 pages)
This chapter describes the design and implementation of the command dispatcher, the module of
the calculator responsible for the creation, storage, and execution of commands. Of particular note
in this chapter is the exposition on the command pattern an
d how it can be used to implement a
practical undo/redo framework. In addition to exploring a traditional deep hierarchy method for
implementing commands, a C++11 alternative using lambda expressions and the standard function
template are presented as a modern alternative design.
1. The Decomposition of the Command Dispatcher
2. The Command Class
3. The Command Repository
4. The Command Manager
5. The Command Dispatcher
6. Revisiting Earlier Decisions
6
Chapter 5: The Command Line Interface (14 pages)
This chapter marks an important milestone, the creation of the first user executable program.
In addition to building a simple command line interface, we’ll explore how to create an abstract
software interface suitable for both a command line interface and a graphical user interface. Within
the context of the command line interface, we’ll le
arn techniques for simple parsing and tokenizing
of input text streams.
1. The User Interface Abstraction
2. The Concrete CLI Class
3. Tying It Together: A Working Program
Chapter 6: The Graphical User Interface (24 pages)
In this chapter, we build the Qt-based graphical user interface for the calculator. Here, we’ll
examine different strategies for building GUIs, abstraction of GUI elements, and modularization of
the overall GUI design. Included in the discussion is design for the separation of on-screen widgets
from look-and-feel.
1. Requirements
2. Building GUIs
3. Modularization
4. A Working Program
5. A Microsoft Windows Build Note
Chapter 7: Plugins (38 pages)
In this chapter, I describe how to build a cross-platform plugin system. This system includes the
abstract interface for C++ plugins as well as the operati
ng system specific mechanics involved with
loading plugins and executing plugin functions. In the concrete case of the plugin loader, I explain
the many build tricks that can be used to handle cross-platform code and demonstrate how the
abstract factory pattern provides an elegant design solution to this problem.
1. What Is a Plugin?
2. Problem 1: The Plugin Interface
3. Problem 2: Loading Plugins
4. Problem 3: Retrofitting pdCalc
5. Incorporating Plugins
6. A Concrete Plugin
7. Next Steps
7
Chapter 8: New Requirements (24 pages)
Any developer who has ever worked on a production software project quickly learns that new
requirements are always added late in the development cycle. In this chapter, we explore the
addition of new user requests after the original requirements have already been satisfied. The
discussion progresses fro
m fully implemented solutions to design only solutions to vague ideas for
the reader to explore on her own.
1. Fully Designed New Features
2. Designs Toward a More Useful Calculator
3. Some Interesting Extensions for Self-Exploration
Appendix A: Acquiring, Building, and Executing pdCalc (4 pages)
This appendix explains how to download the source code from GitHub and how to build the case
study on Linux and Windows. Once the program is built, readers will want to execute the code
and its included test suite; execution instructions are therefore provided.
1. Getting The Source Code
2. Dependencies
3. Building pdCalc
4. Executing pdCalc
Appendix B: Organization of the Source Code (6 pages)
This appendix simply explains the organization of the source tree for pdCalc. This appendix is
useful for finding the locations for the source files refer
enced in the text.
1. The src Directory
2. The test Directory
References (2 pages)
This section lists twenty-nine references cited in the book.
Index (3 pages)
This section is a complete index for the book.