Previous Lecture | lect08 Before Slides | lect08 Annotated Slides | Next Lecture |
Code from lecture
Topics
This lecture and many of the coming lectures require that we understand how our programs interact with computer memory. This is not required to understanding some of the programming constructs like arrays and pointers but is crucial for reasoning about weird program behavior and debugging. So, we will begin with a model of computer memory and then delve into C++ arrays and pointers
C++ arrays
- Intro to lab04
- C/C++ arrays are like lists in Python and Arrays in Java. We will discuss the differences between these.
- Declaring and initializing arrays in C++
- Tracing code involving arrays
- Array pitfalls: out of bound array access
Test driven development
- Write test code and actual code side by side- so your implementation is always tested
- Start with function stubs
- Write the simplest test case and make your code pass that case
- Write another test case, expect your code to fail, see it fail, then add code to pass that test case (and the previous one).
- With every new test case, we have to make sure that all our previous tests still pass - this is a great way to make sure that things that were working before are not broken by new code!