Week 7 - Program Design
Learning objectives
Upon finishing this learning module, you should be able to:
- Design a program using functional decomposition
- Use a test-driven development methodology to develop code
Recommended Schedule
Day 1
Day 2
- Test Driven Development
- Program Design
- Check out the assignment, do the project setup
Day 3
- Design activity
Day 4
- Get started on Arrays from Week 8 - read through 7.2.
- Start CPP Lab Arrays
Online Activity Outline
Multiple file compilation
Read 6.8 and skim LearnCpp.com Chapter 2.10-2.11 which covers header files (not covered well in the book).
This first video shows the desired structure of a multi-file project:
This one shows you how to get .h/.cpp files set up correctly:
This video covers how to compile multiple files from the command prompt:
Combo Projects
Read through the final section of the UnitTesting Guide on creating Combo projects. This video demonstrates how to do the setup:
Test Driven Development
Watch this video that briefly covers the concept of Test Driven Development:
At this point, you should start doing the setup for this week's assignment. If you have a setup problem, ask about it early. It almost certainly is easy to fix, but trying to do so by trial and error is likely to be very frustrating.
Don't worry about solving the real problem, just get your project set up using the setup instructions.
Program Design
Finally, read 6.15 on how to go about designing and building programs using functions. Skip the video in the chapter and use the one below.
This video talks about what makes for a good function:
This video recaps the process of designing the program described in 6.15, but shows using unit tests to help develop it:
Design Activity
Time to practice thinking about designing functions to solve a problem. Here is an activity to practice thinking through a problem and identifying functions. It is designed to take 30-60 minutes depending on how much time you choose to spend on each part.
As you work on it, remember that you are not shooting for perfection... you are just exercising your design muscles.
Here is a sample of what a completed version might look like. After you finish each section, you can compare what you have to that "key". Not to see if you are right or wrong, there are many good ways to attack this problem. Instead, use it to sanity check the format of your work and to see another person's design.
Optional Extras
More on Testing
- A thorough reading on test-driven development.
- If you prefer learning via humorous slide shows, try this: Unit testing presentation (Press arrow keys to advance/backup)
More on Function Design
- LearnCpp.com Chapters 2.6 and 2.13 have some good coverage of how to design functions and programs.