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
- Function Odds & Ends
- Multiple File Compilation
- Read Ch 6.7-6.9 and LearnCpp.com Chapter 2.10-2.11
Day 2
- Unit Testing 2
- Test Driven Development
Day 3
- Function Design
- Program Design
- Read Ch6.15
Day 4
- Arrays Intro
- Read Ch 7.1-7.2
- CPPLab Arrays
Online Activity Outline
Wrap up functions
Read 6.7 & 6.9 - they cover some other techniques that can be used while defining functions. This video recaps the material:
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). Then watch this video that talks about some other techniques for building and documenting complex programs and libraries of functions:
This video covers how to compile multiple files from the command prompt:
Test Driven Development
Read through the final section of the UnitTesting Guide on creating Subdirectory projects. This video demonstrates how to do the setup:
Then 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. Create a Subdirectory project with a "real" program and a unit test project. Make the .h and .cpp files to hold your functions in the real project and link to them from the unit test project. To test the setup, move the sample functions from the unit tests project into the .cpp file in your "real" project, declare them in the .h, and make sure you can still run the tests. 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.
Function and 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.
Arrays
Read Ch 7.1-7.2. These videos covers some of the important (and sometimes unmentioned) details.
Optional Extras
More on Testing
- This stack overflow thread has nice concise descriptions of what unit testing is and why it is good. Read the first three responses to the question.
- If you prefer learning via humorous slide shows, try this: Unit testing presentation (Press arrow keys to advance/backup)
- A thorough reading on test driven development.
More on Function Design
- LearnCpp.com Chapter 2.5 and 2.12 have some good coverage of how to design functions and programs.