Week 3 - Defining and Using Functions
Learning Objectives
Upon finishing this learning module, you should be able to:
- Identify the parameters and return type of functions
- Trace code involving function calls
- Use a unit testing framework to test functions
Schedule
Day 1
- Functions intro
Outside class:
- Start on Functions (Ch 5.1-5.5)
Day 2
- Functions details
Outside class:
- Continue Functions (Ch 5.5-5.11)
- Start on the Ch 5 exercises
Day 3
- Debugger Practice
- Unit testing
Outside class:
- Testing (Ch 5.12-5.16)
- Start in on assignment 3.
Day 4
Outside class:
Recommended Schedule
Day 1
- Start on Functions (Ch 5.1-5.5)
Day 2
- Continue Functions (Ch 5.5-5.11)
- At this point you should be ready to do Ch 5 the exercises
Day 3
- Testing (Ch 5.12-5.16)
- Debugger Practice
Day 4
- Practice pen and paper code
- Start in on assignment 3
- Setting Up a Local Development Environment
Functions
Work through Chapter 5.1-5.11 of the book.
After you have read 5.11, watch this video to learn how to easily write doxygen comments in VS Code:
Testing
Read Ch 5.12-5.16 about testing and watch this video:
For how to do this in a Codespace, watch the following video:
These two pages are a reference for using the Unit Testing framework. Use them if you quickly review how to use Doctest:
Debugger Practice
Watch this video on using the debugger to step through code that uses functions:
Then try the Debugger Practice activity linked in Module 3 of the course.
Practice Pen and Paper Code
The exams in this class will ask you to write small chunks of code on paper. You are not expected to write 100% perfect code, things like a missing ; generally don't count against you. But you are expected to be able to read a problem, identify what kind of code is needed, and sketch out a solution.
It is a little different writing code on paper than it is in a text editor. Especially if you usually write your code by copying and modifying existing code. So this is a first chance to practice the skills you will need for the exams and see if you are retaining enough of the material from the class to be able to write code from scratch.
See the Week 3 Pen and Paper Code activity. It is graded only for completion.
Setting Up a Local Development Environment
You can get through this course just fine using Codespaces.
If you are only taking CS161, you likely don't need to worry about setting up a local environment.
If you are going to continue to CS162 (CS and Engineers), you will eventually want to set up a local environment. So give that a try now. If everything works perfectly, great, you can start using it, especially for quick testing.
Unless you are 100% sure you have the Chemeketa Worklog (Gitdoc) extension set up and working, don't start using a local environment for your assignments. Coontinue using Codespaces in that case or if you want to be able to easily work on your assignment from any computer.
To work locally, you will need to install a code editor (VS Code), a compiler (g++), and Git. Follow the instructions in this guide to set everything up:
Then refer to this guide to learn how to get one of the project templates set up locally: