Week 8 - Function and Program Design

Learning Objectives

Upon finishing this learning module, you should be able to:

  • Design a program using functional decomposition
  • Use multiple files to organize code
  • Use a test-driven development methodology to develop code
This is a very conceptual week. More so than usual, if you just skim the reading looking for questions to answer, you will miss important ideas and struggle on the assignment.

Day 1

In class:

Outside class:


Day 2

In class:

  • Function and program design principles

Outside class:


Day 3

In class:

  • No class (work on reading and set up assignment)

Outside class:


Day 4

In class:

  • Function design activity

Outside class:



Multiple File Programs

Read Ch 6 on Multiple File Programs.

Then do the Using .h/.cpp files walkthrough to get hands-on experience with splitting code into multiple files.

As discussed in Ch 6, there are two ways to break code into multiple files in C++:

  1. Using header files (.h) and implementation files (.cpp)
  2. Using modules (C++20 feature)

The book uses the second method, mostly to reduce the number of files shown in examples.

But support for modules is still spotty in many C++ compilers and IDEs. So we will use the first method (header files and implementation files) for assignments you do that involve splitting code into multiple files.

This video covers the the desired structure of a multi-file project:

This video covers how to compile multiple files from the command prompt:


Function Design

Read Ch 12.1-12.6 on Function Design principles.

This video has some reminders about what makes for a good function (Ch 12.2-12.6):


Program Design and Development

Read the rest of Ch 12 (12.7-12.17) on Program Design and Development principles.

This video briefly covers the concept of Test Driven Development (Ch 12.10):

This video walks through the process of designing a program using a top-down approach. The program is a different example than the one in the book, but the process is the same: