š”– Scriptorium
✦   LIBER   ✦

šŸ“

Practical C++ Design: From Programming to Architecture

āœ Scribed by Adam B. Singer


Publisher
Apress
Year
2021
Tongue
English
Leaves
303
Edition
2
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Go from competent C++ developer to skilled designer or architect using this book as your personal C++ design master class. Updated for the C++20 standard, this title will guide you through the design and implementation of an engaging case study that forms the backdrop for learning the art of applying design patterns and modern C++ techniques to create a high quality, robust application.Ā Ā 

Starting with a quick exploration of the requirements for building the application, you'll delve into selecting an appropriate architecture, eventually designing and implementing all of the necessary modules to meet the project’s requirements. By the conclusion ofĀ Practical C++ Design, you'll have constructed a fully functioning calculator capable of building and executing on any platform that supports both Qt and C++20. Access to the complete source code will help speed your learning.Ā 

Utilize the Model-View-Controller pattern as the basis for the architecture of the calculator; the observer pattern to design an event system; the singleton pattern as you design the calculator’s central data repository, a reusable stack; the command pattern to design a command system supporting unlimited undo/redo; the abstract factory pattern to build a cross-platform plugin infrastructure for extensibility; coroutines to implement a command line interface with a lazy tokenizer; and more.

After reading and using this book, you’ll have begun the transition from C++ programmer to architect.Ā Ā 

What You Will Learn

  • Read a specification document and translate it into a practical C++ design using some of the latest language features from C++20
  • Understand trade-offs in selecting between alternative design scenarios
  • Gain practical experience in applying design patterns to realistic development scenarios
  • Learn how to effectively use language elements of modern C++ to create a lasting design
  • Develop a complete C++ program from a blank canvas through to a fully functioning, cross platform application
  • Read, modify, and extend existing, high quality code
  • Learn the fundamentals of API design, including class, module, and plugin interfaces

Who This Book Is ForĀ 

The experienced C++ developer ready to take the next step to becoming a skilled C++ designer.

✦ Table of Contents


Table of Contents
About the Author
About the Technical Reviewer
Preface
Chapter 1: Defining theĀ Case Study
1.1 A Brief Introduction
1.2 A Few Words About Requirements
1.3 Reverse Polish Notation (RPN)
1.4 The Calculator’s Requirements
1.5 The Source Code
Chapter 2: Decomposition
2.1 The Elements ofĀ aĀ Good Decomposition
2.2 Selecting anĀ Architecture
2.2.1 Multitiered Architecture
2.2.2 Model-View-Controller (MVC) Architecture
2.2.3 Architectural Patterns Applied toĀ theĀ Calculator
2.2.4 Choosing theĀ Calculator’s Architecture
2.3 Interfaces
2.3.1 Calculator Use Cases
Use Case: User enters aĀ floating-point number onto theĀ stack
Use Case: User undoes last operation
Use Case: User redoes last operation
Use Case: User swaps top stack elements
Use Case: User drops theĀ top stack element
Use Case: User clears theĀ stack
Use Case: User duplicates theĀ top stack element
Use Case: User negates theĀ top stack element
Use Case: User performs anĀ arithmetic operation
Use Case: User performs aĀ trigonometric operation
Use Case: User performs y x
Use Case: User performs
Use Case: User loads aĀ plugin
2.3.2 Analysis ofĀ Use Cases
2.3.3 A Quick Note onĀ Actual Implementation
2.4 Assessment ofĀ Our Current Design
2.5 Implementing Our Design Using C++20 Modules
2.5.1 Why Modules?
2.5.2 Using Legacy Headers
2.5.3 Source Code Organization Prior toĀ C++20
2.5.4 Source Code Organization Using C++20 Modules
2.5.5 Modules andĀ pdCalc
Refining pdCalc’s Modules
Code Representation ofĀ Modules inĀ pdCalc
Modules andĀ DLLs forĀ pdCalc
2.6 Next Steps
Chapter 3: The Stack
3.1 Decomposition ofĀ theĀ Stack Module
3.2 The Stack Class
3.2.1 The Singleton Pattern
3.2.2 The Stack Module AsĀ aĀ Singleton Class
3.3 Adding Events
3.3.1 The Observer Pattern
Enhancing theĀ Observer Pattern Implementation
Handling Event Data
3.3.2 The Stack AsĀ anĀ Event Publisher
3.3.3 The Complete Stack Module Interface
3.4 A Quick Note onĀ Testing
Chapter 4: The Command Dispatcher
4.1 Decomposition ofĀ theĀ Command Dispatcher
4.2 The Command Class
4.2.1 The Command Pattern
4.2.2 More onĀ Implementing Undo/Redo
4.2.3 The Command Pattern Applied toĀ theĀ Calculator
The Command Interface
The Undo Strategy
Concrete Commands
An Alternative toĀ Deep Command Hierarchies
4.3 The Command Factory
4.3.1 The CommandFactory Class
4.3.2 Registering Core Commands
4.4 The Command Manager
4.4.1 The Interface
4.4.2 Implementing Undo andĀ Redo
4.5 The Command Interpreter
4.5.1 The Interface
The Pimpl Idiom
Do Modules Obviate theĀ Pimpl Idiom?
4.5.2 Implementation Details
4.6 Revisiting Earlier Decisions
Chapter 5: The Command Line Interface
5.1 The User Interface Abstraction
5.1.1 The Abstract Interface
5.1.2 User Interface Events
Command Data
User Interface Observers
5.2 The Concrete CLI Class
5.2.1 Requirements
5.2.2 The CLI Design
The Interface
The Implementation
5.3 Tying It Together: AĀ Working Program
Chapter 6: The Graphical User Interface
6.1 Requirements
6.2 Building GUIs
6.2.1 Building GUIs inĀ IDEs
6.2.2 Building GUIs inĀ Code
6.2.3 Which GUI Building Method Is Better?
6.3 Modularization
6.3.1 The CommandButton Abstraction
The CommandButton Design
The CommandButton Interface
6.3.2 Getting Input
The Design ofĀ theĀ InputWidget
The Interface ofĀ theĀ InputWidget
6.3.3 The Display
The Design ofĀ theĀ Display Class
A Poor Design
An Improved Display Design
6.3.4 The Model
6.3.5 The Display Redux
6.3.6 Tying It Together: TheĀ Main Window
6.3.7 Look-and-Feel
6.4 A Working Program
6.5 A Microsoft Windows Build Note
Chapter 7: Plugins
7.1 What Is aĀ Plugin?
7.1.1 Rules ForĀ C++ Plugins
7.2 Problem 1: TheĀ Plugin Interface
7.2.1 The Interface forĀ Discovering Commands
7.2.2 The Interface forĀ Adding New GUI Buttons
7.2.3 Plugin Allocation andĀ Deallocation
7.2.4 The Plugin Command Interface
7.2.5 API Versioning
7.2.6 Making theĀ Stack Available
7.3 Problem 2: Loading Plugins
7.3.1 Platform-Specific Plugin Loading
7.3.2 Loading, Using, andĀ Closing aĀ Shared Library
7.3.3 A Design forĀ Multiplatform Code
The Obvious Solution: Libraries
Raw Preprocessor Directives
(Slightly) More Clever Preprocessor Directives
A Build System Solution
A Platform Factory Function
An Abstract Factory forĀ Generalized Platform-Independent Code
7.4 Problem 3: Retrofitting pdCalc
7.4.1 Injecting Commands
7.4.2 Adding Plugin Buttons toĀ theĀ GUI
7.5 Incorporating Plugins
7.5.1 Loading Plugins
7.5.2 Injecting Functionality
7.6 A Concrete Plugin
7.6.1 Plugin Interface
7.6.2 Source Code Dependency Inversion
7.6.3 Implementing HyperbolicLnPlugin’s Functionality
7.7 Next Steps
Chapter 8: New Requirements
8.1 Fully Designed New Features
8.1.1 Batch Operation
8.1.2 Stored Procedures
The User Interface
Changes toĀ theĀ Command Dispatcher Module
Designing theĀ StoredProcedure Class
The Composite Pattern
A First Attempt
A Final Design forĀ theĀ StoredProcedure Class
8.2 Designs Toward aĀ More Useful Calculator
8.2.1 Complex Numbers
Modifying Input andĀ Output
Modifying theĀ Stack
Modifying Commands
8.2.2 Variables
Input andĀ New Commands
Number Representation andĀ theĀ Stack
The Symbol Table
A Trivial Extension: Numeric Constants
Functionality Enabled by Variables
8.3 Some Interesting Extensions for Self-Exploration
8.3.1 High DPI Scaling
8.3.2 Dynamic Skinning
8.3.3 Flow Control
8.3.4 An Alternative GUI Layout
8.3.5 A Graphing Calculator
8.3.6 A Plugin Management System
8.3.7 A Mobile Device Interface
8.3.8 pdCalc inĀ theĀ Cloud
Appendix A:
Acquiring, Building, and Executing pdCalc
A.1 Getting theĀ Source Code
A.2 Dependencies
A.3 Building pdCalc
A.3.1 Using Qt Creator
A.3.2 Using theĀ Command Line
A.4 Executing pdCalc
A.4.1 Using Qt Creator
A.4.2 Using theĀ Command Line
A.5 Troubleshooting
Appendix B:
Organization of the Source Code
B.1 The src Directory
B.1.1 The 3rdParty Directory
B.1.2 The app/pdCalc Directory
B.1.3 The app/pdCalc-simple-cli Directory
B.1.4 The app/pdCalc-simple-gui Directory
B.1.5 The utilities Directory
B.1.6 The backend Directory
B.1.7 The ui Directory
B.1.8 The plugins Directory
B.2 The test Directory
B.2.1 The testDriver Directory
B.2.2 The utilitiesTest Directory
B.2.3 The backendTest Directory
B.2.4 The uiTest Directory
B.2.5 The pluginsTest Directory
References
Index

✦ Subjects


C++; Software Design; Software Architecture; Software Design Patterns; Design Patterns


šŸ“œ SIMILAR VOLUMES


Practical C++ Design: From Programming t
āœ Adam B. Singer šŸ“‚ Library šŸ“… 2021 šŸ› Apress 🌐 English

<p>Go from competent C++ developer to skilled designer or architect using this book as your personal C++ design master class. Updated for the C++20 standard, this title will guide you through the design and implementation of an engaging case study that forms the backdrop for learning the art of appl

Practical C++ Design: From Programming t
āœ Adam B. Singer šŸ“‚ Library šŸ“… 2021 šŸ› Apress 🌐 English

<p>Go from competent C++ developer to skilled designer or architect using this book as your personal C++ design master class. Updated for the C++20 standard, this title will guide you through the design and implementation of an engaging case study that forms the backdrop for learning the art of appl

Practical C++ Design: From Programming t
āœ Adam B. Singer šŸ“‚ Library šŸ“… 2017 šŸ› Apress 🌐 English

<div>Go from competent C++ developer to skilled designer or architect using this book as your C++ design master class. This title will guide you through the design and implementation of a fun, engaging case study. Starting with a quick exploration of the requirements for building the application, yo

Practical C++ Design: From Programming t
āœ Adam B. Singer šŸ“‚ Library šŸ“… 2017 šŸ› Apress 🌐 English

<div>Go from competent C++ developer to skilled designer or architect using this book as your C++ design master class. This title will guide you through the design and implementation of a fun, engaging case study. Starting with a quick exploration of the requirements for building the application, yo

C# Programming: From Problem Analysis to
āœ Barbara Doyle šŸ“‚ Library šŸ“… 2007 šŸ› Course Technology 🌐 English

Master the problem-solving skills and techniques associated with object-oriented program development using this hands-on, reader-friendly text. C# Programming: From Problem Analysis to Program Design, Second Edition, introduces a variety of basic programming concepts, from data types and expressions

C# Programming: From Problem Analysis to
āœ Barbara Doyle šŸ“‚ Library šŸ“… 2013 šŸ› Cengage Learning 🌐 English

Only Doyle's C# PROGRAMMING: FROM PROBLEM ANALYSIS TO PROGRAM DESIGN, 4E brilliantly balances today's most important programming principles and concepts with the latest insights into C#. This perfect introductory book highlights the latest Visual Studio 2012 and C# 4.0 with a unique, principles-base