Singer | Practical C++ Design | E-Book | www2.sack.de
E-Book

E-Book, Englisch, 257 Seiten

Singer Practical C++ Design

From Programming to Architecture
1. ed
ISBN: 978-1-4842-3057-2
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

From Programming to Architecture

E-Book, Englisch, 257 Seiten

ISBN: 978-1-4842-3057-2
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



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, 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 that builds and executes on multiple platforms. Access to the complete source code will help speed your learning.
Utilize the Model-View-Controller pattern to determine the optimal architecture for 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; and the abstract factory pattern for a cross-platform plugin infrastructure to make the calculator extensible.
What You Will Learn:
Learn to read a specification document and translate it into a practical C++ design
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 applicationLearn to read, modify, and extend an existing, high quality code
Learn the fundamentals of API design, including class, module, and plugin interfaces
Who This Book Is For:
Practical C++ Design is a book designed for the experienced C++ developer ready to take the next step to becoming a skilled C++ designer.


Adam B. Singer graduated first in his class at the Georgia Institute of Technology in 1999 with a bachelors degree in chemical engineering. He subsequently attended the Massachusetts Institute of Technology on a National Defense, Science, and Engineering Graduate Fellowship. He graduated from MIT with a Ph.D. in chemical engineering in 2004 after defending his thesis titled Global Dynamic Optimization. 
Since graduation, Adam has been a member of the research and engineering staff at an oil and gas major, where he has worked in software development, design, and project management in areas such as optimization, reservoir simulation, decision support under uncertainty, basin modeling, well log modeling, and stratigraphy. He has also served on and chaired committees designing in-house training in the areas of technical software development and computational and applied mathematics. He currently holds a research supervisory position.

Adam additionally held the title of adjunct assistant professor in the Department of Computational and Applied Mathematics at Rice University from 2007-2012. In both 2006 and 2007, he taught a graduate level course, CAAM 520, on computational science. The course focused on the design and implementation of high performance parallel programs.

Singer Practical C++ Design jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Table of Contents;5
2;About the Author;11
3;About the Technical Reviewer;12
4;Preface;13
5;Chapter 1: Defining the Case Study;19
5.1;1.1 A Brief Introduction;19
5.2;1.2 A Few Words About Requirements;20
5.3;1.3 Reverse Polish Notation;21
5.4;1.4 The Calculator’s Requirements;23
5.5;1.5 The Source Code;24
6;Chapter 2: Decomposition;26
6.1;2.1 The Elements of a Good Decomposition;27
6.2;2.2 Selecting an Architecture;29
6.2.1;2.2.1 Multi-Tiered Architecture;29
6.2.2;2.2.2 Model-View-Controller (MVC) Architecture;31
6.2.3;2.2.3 Architectural Patterns Applied to the Calculator;32
6.2.4;2.2.4 Choosing the Calculator’s Architecture;33
6.3;2.3 Interfaces;34
6.3.1;2.3.1 Calculator Use Cases;35
6.3.1.1;2.3.1.1 Use Case: User Enters a Floating Point Number onto the Stack;35
6.3.1.2;2.3.1.2 Use Case: User Undoes Last Operation;35
6.3.1.3;2.3.1.3 Use Case: User Redoes Last Operation;35
6.3.1.4;2.3.1.4 Use Case: User Swaps Top Stack Elements;35
6.3.1.5;2.3.1.5 Use Case: User Drops the Top Stack Element;36
6.3.1.6;2.3.1.6 Use Case: User Clears the Stack;36
6.3.1.7;2.3.1.7 Use Case: User Duplicates the Top Stack Element;36
6.3.1.8;2.3.1.8 Use Case: User Negates the Top Stack Element;36
6.3.1.9;2.3.1.9 Use Case: User Performs an Arithmetic Operation;36
6.3.1.10;2.3.1.10 Use Case: User Performs a Trigonometric Operation;37
6.3.1.11;2.3.1.11 Use Case: User Performs yx;37
6.3.1.12;2.3.1.12 Use Case: User Performs;37
6.3.1.13;2.3.1.13 Use Case: User Loads a Plugin;37
6.3.2;2.3.2 Analysis of Use Cases;38
6.3.3;2.3.3 A Quick Note on Actual Implementation;44
6.4;2.4 Assessment of Our Current Design;45
6.5;2.5 Next Steps;45
7;Chapter 3: The Stack;47
7.1;3.1 Decomposition of the Stack Module;47
7.2;3.2 The Stack Class;50
7.2.1;3.2.1 The Singleton Pattern;50
7.2.2;3.2.2 The Stack Module as a Singleton Class;52
7.2.2.1;3.2.2.1 The Pimpl Idiom;54
7.3;3.3 Adding Events;56
7.3.1;3.3.1 The Observer Pattern;57
7.3.1.1;3.3.1.1 Enhancing the Observer Pattern Implementation;58
7.3.1.2;3.3.1.2 Handling Event Data;63
7.3.2;3.3.2 The Stack as an Event Publisher;68
7.3.3;3.3.3 The Complete Stack Interface;69
7.4;3.4 A Quick Note on Testing;70
8;Chapter 4: The Command Dispatcher;72
8.1;4.1 Decomposition of the Command Dispatcher;72
8.2;4.2 The Command Class;73
8.2.1;4.2.1 The Command Pattern;73
8.2.2;4.2.2 More on Implementing Undo/Redo;74
8.2.3;4.2.3 The Command Pattern Applied to the Calculator;76
8.2.3.1;4.2.3.1 The Command Interface;76
8.2.3.2;4.2.3.2 The Undo Strategy;85
8.2.3.3;4.2.3.3 Concrete Commands;90
8.2.3.4;4.2.3.4 An Alternative to Deep Command Hierarchies;91
8.3;4.3 The Command Repository;96
8.3.1;4.3.1 The CommandRepository Class;96
8.3.2;4.3.2 Registering Core Commands;102
8.4;4.4 The Command Manager;103
8.4.1;4.4.1 The Interface;103
8.4.2;4.4.2 Implementing Undo and Redo;104
8.5;4.5 The Command Dispatcher;106
8.5.1;4.5.1 The Interface;107
8.5.2;4.5.2 Implementation Details;108
8.6;4.6 Revisiting Earlier Decisions;110
9;Chapter 5: The Command Line Interface;112
9.1;5.1 The User Interface Abstraction;112
9.1.1;5.1.1 The Abstract Interface;113
9.1.2;5.1.2 User Interface Events;116
9.1.2.1;5.1.2.1 Command Data;117
9.1.2.2;5.1.2.2 User Interface Observers;118
9.2;5.2 The Concrete CLI Class;120
9.2.1;5.2.1 Requirements;120
9.2.2;5.2.2 The CLI Design;122
9.2.2.1;5.2.2.1 The Interface;122
9.2.2.2;5.2.2.2 The Implementation;123
9.3;5.3 Tying It Together: A Working Program;127
10;Chapter 6: The Graphical User Interface;129
10.1;6.1 Requirements;129
10.2;6.2 Building GUIs;132
10.2.1;6.2.1 Building GUIs in IDEs;133
10.2.2;6.2.2 Building GUIs in Code;134
10.2.3;6.2.3 Which GUI Building Method Is Better?;135
10.3;6.3 Modularization;136
10.3.1;6.3.1 The CommandButton Abstraction;136
10.3.2;6.3.2 The CommandButton Design;137
10.3.3;6.3.3 The CommandButton Interface;141
10.3.4;6.3.4 Getting Input;143
10.3.5;6.3.5 The Design of the InputWidget;143
10.3.6;6.3.6 The Interface of the InputWidget;145
10.4;6.4 The Display;146
10.4.1;6.4.1 The Design of the Display Class;148
10.4.2;6.4.2 A Poor Design;148
10.4.3;6.4.3 An Improved Display Design;149
10.5;6.5 The Model;150
10.6;6.6 The Display Redux;152
10.7;6.7 Tying It Together: The Main Window;153
10.8;6.8 Look-and-Feel;155
10.9;6.9 A Working Program;156
10.10;6.10 A Microsoft Windows Build Note;158
11;Chapter 7: Plugins;159
11.1;7.1 What Is a Plugin?;159
11.1.1;7.1.1 Rules for C++ Plugins;160
11.2;7.2 Problem 1: The Plugin Interface;163
11.2.1;7.2.1 The Interface for Discovering Commands;163
11.2.2;7.2.2 The Interface for Adding New GUI Buttons;168
11.2.3;7.2.3 Plugin Allocation and Deallocation;170
11.2.4;7.2.4 The Plugin Command Interface;170
11.2.5;7.2.5 API Versioning;173
11.2.6;7.2.6 Making the Stack Available;174
11.3;7.3 Problem 2: Loading Plugins;175
11.3.1;7.3.1 Platform-Specific Plugin Loading;176
11.3.2;7.3.2 Loading, Using, and Closing a Shared Library;176
11.3.3;7.3.3 A Design for Multi-Platform Code;178
11.3.3.1;7.3.3.1 The Obvious Solution: Libraries;179
11.3.3.2;7.3.3.2 Raw Preprocessor Directives;179
11.3.3.3;7.3.3.3 (Slightly) More Clever Preprocessor Directives;180
11.3.3.4;7.3.3.4 A Build System Solution;181
11.3.3.5;7.3.3.5 A Platform Factory Function;182
11.3.3.6;7.3.3.6 An Abstract Factory for Generalized Platform Independent Code;186
11.4;7.4 Problem 3: Retrofitting pdCalc;191
11.4.1;7.4.1 Module Interfaces;192
11.4.1.1;7.4.1.1 Source Code Hiding;192
11.4.1.2;7.4.1.2 DLL Hiding;193
11.4.1.3;7.4.1.3 Implicit or Documentation Hiding;195
11.4.1.4;7.4.1.4 Module Design for pdCalc;195
11.4.2;7.4.2 Adding Plugin Buttons to the GUI;196
11.5;7.5 Incorporating Plugins;197
11.5.1;7.5.1 Loading Plugins;198
11.5.2;7.5.2 Injecting Functionality;199
11.6;7.6 A Concrete Plugin;201
11.6.1;7.6.1 Plugin Interface;201
11.6.2;7.6.2 Source Code Dependency Inversion;203
11.6.3;7.6.3 Implementing HyperbolicLnPlugin’s Functionality;204
11.7;7.7 Next Steps;207
12;Chapter 8: New Requirements;208
12.1;8.1 Fully Designed New Features;208
12.1.1;8.1.1 Batch Operation;209
12.1.2;8.1.2 Stored Procedures;210
12.1.2.1;8.1.2.1 The User Interface;212
12.1.2.2;8.1.2.2 Changes to the Command Dispatcher;213
12.1.2.3;8.1.2.3 Designing the StoredProcedure Class;217
12.1.2.4;8.1.2.4 The Composite Pattern;218
12.1.2.5;8.1.2.5 A First Attempt;219
12.1.2.6;8.1.2.6 A Final Design for the StoredProcedure Class;221
12.2;8.2 Designs Toward a More Useful Calculator;224
12.2.1;8.2.1 Complex Numbers;224
12.2.1.1;8.2.1.1 Modifying Input and Output;225
12.2.1.2;8.2.1.2 Modifying the Stack;227
12.2.1.3;8.2.1.3 Modifying Commands;229
12.2.2;8.2.2 Variables;229
12.2.2.1;8.2.2.1 Input and New Commands;230
12.2.2.2;8.2.2.2 Number Representation and the Stack;231
12.2.2.3;8.2.2.3 The Symbol Table;232
12.2.2.4;8.2.2.4 A Trivial Extension: Numeric Constants;233
12.2.2.5;8.2.2.5 Functionality Enabled by Variables;233
12.3;8.3 Some Interesting Extensions for Self-Exploration;234
12.3.1;8.3.1 High DPI Scaling;234
12.3.2;8.3.2 Dynamic Skinning;234
12.3.3;8.3.3 Flow Control;235
12.3.4;8.3.4 An Alternative GUI Layout;235
12.3.5;8.3.5 A Graphing Calculator;235
12.3.6;8.3.6 A Plugin Management System;236
12.3.7;8.3.7 A Mobile Device Interface;236
13;Appendix A: Acquiring, Building, and Executing pdCalc;237
13.1; A.1 Getting the Source Code;237
13.2; A.2 Dependencies;237
13.3; A.3 Building pdCalc;238
13.3.1;A.3.1 Using Qt Creator;239
13.3.2; A.3.2 Using the Command Line;240
13.4; A.4 Executing pdCalc;241
13.4.1;A.4.1 Using Qt Creator;241
13.4.2; A.4.2 Using the Command Line;241
13.5; A.5 Troubleshooting;242
14;Appendix B: Organization of the Source Code;245
14.1; B.1 The src Directory;245
14.1.1;B.1.1 The pdCalc Directory;245
14.1.2; B.1.2 The pdCalc-simple-cli Directory;246
14.1.3; B.1.3 The pdCalc-simple-gui Directory;246
14.1.4; B.1.4 The utilities Directory;246
14.1.5; B.1.5 The backend Directory;246
14.1.6; B.1.6 The cli Directory;247
14.1.7; B.1.7 The gui Directory;248
14.1.8; B.1.8 The plugins Directory;248
14.2; B.2 The test Directory;248
14.2.1;B.2.1 The testDriver Directory;249
14.2.2; B.2.2 The utilitiesTest Directory;249
14.2.3; B.2.3 The backendTest Directory;249
14.2.4; B.2.4 The cliTest Directory;250
14.2.5; B.2.5 The guiTest Directory;250
14.2.6; B.2.6 The pluginsTest Directory;250
15;References;251
16;Index;254



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.