SoftwareHills Home

C++ Physical Design

How to organize and build large C++ software

Introduction
Table of contents
Chapters overview
Free PDF Downloads
Order now

C++ software development has many problems that are originated from the physical organization of the source code and from the systems used to build the compiled programs. Such problems are usually called the "physical design" in contrast with the "logical design" which is the internal design of the software through the rules of the programming language.

This book faces the problems of C++ physical design through an accurate analysis and provides good solutions, with detailed explanations of their validity and examples taken from real projects.

The central argument of this book is a new way to organize C++ libraries, based on the right placement of include directives, the use of some reserved header files, and the use of precompiled headers. The problem of precompiled headers is treated deeply and extensively since its extreme importance in building large software.

This book shows how to achieve in C++ something like the Java packages, which is very useful because it allows to maintain the typical features of C++ programs and at the same time to expand a C++ software with very few limits, like it is easy to do in other programming environments.

Most of the problems described in this book are common to both C and C++, the focus of the analysis is on C++ projects but the solutions exposed are valid also for pure C projects.

This book is a complement to the knowledge of a C++ developer, because even with the best design patterns and lots of practice the large projects have problems caused by the absence of the concept of module in C++. To use effectively this book the reader should have a fairly complete knowledge of the C/C++ programming language and a bit of practice of real C++ software development.

Two chapters of this book are freely downloadable in PDF format or HTML format. For some other discussion of problems of source code organization read also this article which examines the flaws of a design also discussed in the book.

Introduction

C++ is a powerful and widespread programming language but it hasn't got an embedded support for modularization of large projects.

In programming courses and manuals there is very little about how to organize and build large collections of C++ source code.

There are lots of books about the C++ programming language and many of them are good sources to learn the C++ syntax and the Object Oriented Programming, on the contrary, there are very few books about the concrete problems of software development in C++.

Commercial IDEs (Integrated Development Environment) are very good for creating and debugging small projects but often they miss those features that are very useful when the project grows.

Physical design, which consists in the design of the set of source files rather than the program structures, is an important part of a C/C++ software project.

With a bad or just inaccurate physical design the development can stop because of many problems:

Table of contents

Chapters overview

Chapter 1 introduces the point of view adopted in the book, the concept of C++ program as a set of class libraries, and the essentially flat name space of C++. Then it summarizes the problems arising in large C++ projects.

Chapter 2 describes the different build strategies available for building a large C++ program: single builds, static libraries and dynamic link libraries (DLL), tells about their advantages and disadvantages, describes the problems of DLLs in C++ and the use of the export marker, and finally shows some problems of the commercial IDEs available today.

Chapter 3 describes the different kinds of dependencies that exist among source files and whole libraries. It shows the importance of avoiding cyclic dependencies and the advantages of grouping the libraries in levels. Then it shows the need of a construction sequence for a set of libraries. Finally it describes the problems that a source code dependency extractor must resolve.

Chapter 4 describes the actual build process of a C++ program, how the source code files are turned into executables or library files, how the build system can avoid unneeded recompilation of files. Then the chapter describes good ways to organize DLL files and the problems of creating a setup package.

Chapter 5 describes and compares some possible solutions to organize the source code in a set of libraries. The solutions are aimed to reduce the build times and remove the unneeded dependencies. A very good solution is described in detail and it requires only reserved headers and rules about include directives. With the use of precompiled headers this solution becomes a complete way of organizing, defining and building C++ software modules.

Chapter 6 shows how to use efficiently the precompiled headers that are available in most modern compilers. The problems of precompiled headers are analyzed deeply and complete solutions are provided. Finally there are some notes about particular C++ development environments both commercial and open source.

Chapter 7 is about the configurations of the compiling tools. It describes a model of all possible configurations of any known compiler. It shows the importance of configuration files, and it describes a possible application to manage the configurations.

Chapter 8 speaks about the problem of documenting the C++ source code, and it shows the advantages of having a separate documentation files rather than embedding documentation in source code with comments. It provides a rational point of view of the C++ family of entities, like a catalog of parts of a machine.

Chapter 9 is about the main metrics of the C++ source code, since this arguments is recurring during development of large projects. It discusses the meaning of the software metrics and shows some basic metrics for the C++ code.

Chapter 10 is a short presentation of some C++ programming patterns that are related to the physical design. It also describes other possible solutions to organize the C++ code in multiple modules by means of the explicit loading of dynamic link libraries.

Free PDF downloads

Table of contents
Chapter 1
Chapter 3

Order a printed copy now

This book is currently out of print but if you want it the author can print a copy on demand. It would take just 1 - 2 days to print and bind a copy. The printed book has 130 pages, 18.5 x 24 cm format.

You can pay the printed copy of this book by means of PayPal. The price is 25 EUR plus shipping as shown below. The email address for PayPal payments is mail@softwarehills.com, or you can select your correct shipping zone below and then click on the button to open the secure PayPal site for the payment procedure.

Shipping zone

See also this software, that provides some tools for the C++ source organization like described in the book.