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
Recommended Schedule
Day 1
In class:
- Multiple File Programs
- Do the Using .h/.cpp files walkthrough
Outside class:
- Read about Multiple File Programs (Ch 6)
Day 2
In class:
- Function and program design principles
Outside class:
- Read about Function Design principles (Ch 12.1-12.6)
Day 3
In class:
- No class (work on reading and set up assignment)
Outside class:
- Start reading about Program Design and Development principles (Ch 12.7-12.11)
Day 4
In class:
- Function design activity
Outside class:
- Finish reading about Program Development and Development principles (Ch 12.12-12.17)
- Checkout assignment
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++:
- Using header files (.h) and implementation files (.cpp)
- 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: