Home > Articles > Programming > C/C++

Going Large-Scale with C++, Part 1: Successful Small Projects Will Often Grow

  • Print
  • + Share This
A single-purpose application with efficient, error-free code is a beautiful dream. In the real world, however, software is typically created by groups working with nearly impossible challenges against tight deadlines. Must successful small programs inevitably become unwieldy behemoths? In this two-part series, John Lakos, author of Large-Scale C++ LiveLessons (Workshop): Applied Hierarchical Reuse Using Bloomberg's Foundation Libraries, explains why large development efforts are fundamentally different from small ones, and explores methodologies for meeting this scalability challenge.

Read Part 2.

Like this article? We recommend


Developing software on any scale can be challenging, but developing software on a large scale is qualitatively different. As in the construction industry, many processes and techniques work handily for a small team creating a simple product (such as a single-family home or a single-purpose app) over a few months' time. The same processes and techniques would fall short if applied to substantially larger development efforts (like a fifty-story skyscraper or complex organization-wide software).

Software development of any kind requires intelligence. Successful large-scale software development, however, also demands engineering and discipline. Unlike the creation of small ad hoc programs, large-scale software development is an engineering discipline unto itself—independent of the subject domains to which it is applied.

Large-scale projects often encompass a variety of dimensions, including

  • Size and scope of the code base
  • Time horizon
  • Development team
  • Client requirements

This two-part series explores how the essential nature of successful software development changes as we progress toward larger, longer-term, and more widely distributed development efforts. This article examines how small software projects can take advantage of large-scale methodologies to produce better individual results today, as well as preparing for the prodigious growth that many successful software products experience. Part 2 of this series examines how scale affects the individual (application) programs, the hierarchically reusable libraries, and the ultimate service-oriented systems that result from using these techniques.

Separate Physical Components

A very small development effort that results in a single executable program is a pure application of both the language and whatever libraries are available. Development of such software typically addresses a current need, without regard for the needs of other programs, and (perhaps) even potential changes to that same program in the future.

When the amount of application software we need to develop exceeds what will reasonably fit within a single file that also holds main, we are no longer solving only the domain-specific problem we initially set out to address, but are now also obliged to structure that solution physically in a way that makes the code easy to understand, test, and maintain. That is, we must consider how to partition our logical application code into separate physical units. We refer to these fundamental physical units as components, which, in C++, take the form of .h/.cpp pairs.

In all programming languages, components satisfy certain critical properties that avoid established physical design flaws:

  • Cyclic (physical) dependencies among components
  • Private access across component boundaries (such as long-distance "friendship" in C++)

Intra-Application Reuse

Once a body of software exceeds what will reasonably fit within a single directory or Unit of Release (UOR), we must decide what aspects to keep close to the application main (and leave malleable) and what we will segregate physically into separate library UORs (and keep stable).

At this juncture we leave the realm of pure domain-specific problem solving and confront the discipline of software engineering full on. Writing stable software is inherently more costly in the short term, but it can pay dividends, through reuse, in the form of reduced code size and improved maintainability. After determining what functionality we can make stable, we must decide how to factor and package it into discrete UORs. During development, these UORs can be used independently when unit-testing disparate parts of the application.

Multiple Development Groups

Intensifying development effort over a fixed period of time necessarily requires more developers—each with his or her own view on how software should be written and packaged. (Remember that your existing development staff will also have to hire additional competent software engineers and then train them in the established software-development methodology.)

A handful of programmers collaborating on a single application could probably produce something viable through ad hoc methods. When the number of people working on a project exceeds that threshold, an informal approach becomes increasingly less likely to produce acceptable results. A small, locally situated development team might take simple design interactions for granted, but that advantage will evaporate if teams are dispersed geographically—especially across disparate time zones.

When working separately, no group should "fiddle" with foundational code in a way that breaks assumptions made by other groups. For example, one development team's modifying the program-wide "locale" could potentially break code that is not prepared to handle a character other than a period (.) as the decimal sign. The need for additional levels of management, including project managers, soon becomes inevitable.

Source Control/Versioning

Even the smallest project can benefit from a source-code control system, but source control is indispensable when a project is expected to grow to more than one developer or a few file directories. A source control system must be able to diagnose conflicting changes or regressions; coordinate contributions from multiple developers; and facilitate, across its internally maintained branches, the separation of production code from new-feature development.

Effective Build Systems

A small project might be built with a single command-line invocation of the compiler, whereas a large project with multiple UORs requires a more sophisticated build system. At minimum, a set of hierarchical makefiles would be needed to build the entire system out of its sub-parts. Many projects benefit from a tool (such as Waf) that understands the dependencies among components, along with those of physical aggregates such as packages and package groups. Such tools can automatically build and install libraries and header files for multiple/different target platforms.

Other Useful Support Tools

Several commonly available development tools become increasingly enticing as project and team sizes expand. For example, code-review tools (such as Phabricator) allow geographically dispersed teams to perform code reviews without needing to meet in a single room or even at the same time. Tools that maintain a database of every use of each class, function, or variable can provide an invaluable service for refactoring a code base, helping to mitigate cries of "We did it wrong two years ago and now we can't ever fix it." Some of these support tools are part of IDEs or are available as plug-ins, making the tools easier to use in projects based on those IDEs.

Coherent, Nominally Cohesive Packaging

With increasing numbers of cooperating developers, it becomes important to establish a coherent, nominally cohesive, uniform logical and physical structure for the software under development:

  • Coherent: The definition of the logical content that performs some subset of functionality resides in a well-defined, contiguous sub-region of the physical architecture (while still permitting dependencies on more general, lower-level components).
  • Nominally cohesive: Just by looking at how the software is used in a program, we can identify its location (definition, documentation, and tests) in the enterprise-wide physical hierarchy. In C++, we can employ the namespace construct to achieve both nominal cohesion and unique naming, so long as we avoid using directives and declarations.

Admitting Third-Party and Open-Source Libraries

The internally consistent structure I have described may well differ from that of software developed elsewhere. However, given the vast quantities of third-party and open-source libraries available today, this homogeneous structure must accommodate the use of such foreign software. The industry has standardized on a small number of systems and platforms for storing open-source software, and for packaging programs and libraries for installation. For open-source software distributions to be well received—internally and externally—they must fit smoothly into this ecosystem.

Terse, Unique, and Distributed Names

One simple way to encourage retaining namespaces for qualification purposes only is to limit such use to a single level and keep the names blissfully short (for example, std). For this approach to work, the enterprise (as a whole) has to make some very deliberate decisions, such as requiring every component to belong to exactly one package, and qualify all architecturally significant names—logical and physical—by a unique package name. Packages can be assembled into groups that share the same envelope of physical dependencies on other UORs.

A centralized registrar could dispense very short package-group names of uniform length (perhaps three characters, such as bdl for "BDE Development Library"). This design allows for the decentralized minting of short enterprise-wide unique package names (e.g., 4–6 characters, such as bdlma for "BDE Development Library Memory Allocators"). These short (package) names contain and display the (even shorter) package-group name prefix, bdl, without necessitating any further global interaction or superfluous syntax.


The takeaway message here is that large development efforts are fundamentally different from small ones, and lessons learned in larger efforts inform smaller ones, but not vice versa. Successful small efforts almost inevitably become larger. When working on tiny projects, employ the same techniques you would use on larger projects that naturally scale.

Use a consistent scalable methodology across all projects in your enterprise. This practice ensures that successful projects can grow, and facilitates developer mobility away from less successful ones. Always think big, and plan for the long term up front (or at least repair any "cut corners" immediately after meeting a critical short-term deadline) in order to avoid immensely debilitating long-term technical debt.

Part 2 of this series explores additional opportunities for improving our effectiveness as software development efforts continue to grow. In particular, we'll see how, by keeping our individual components small and focused, and adhering to a small set of canonical class categories, we can realize truly profound efficiencies through hierarchical reuse.

  • + Share This
  • 🔖 Save To Your Account