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
Schedule
Day 1
- Holiday
Day 2
Day 3
- Test Driven Development
- Program Design
- Check out the assignment, do the project setup
Day 4
- Design activity
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.
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:
Start working on the actual code for the assignment.
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 in 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 what you see here. Not to see if you are right or wrong, there are many ways to attack this problem, but just to sanity check the format of your work and to see another person's version of designing some functions.
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 Chapter 2.5 and 2.12 have some good coverage of how to design functions and programs.