Week 2 - Introduction to Object-Oriented Programming (OOP)
Learning objectives
- Design classes to represent data types in C++
- Construct and read UML class diagrams
- Write basic object-oriented programs using common design principles
Schedule
Day 1
- Start on Object Oriented Programming - Ch 16.1-16.6
Day 2
- Continue Object Oriented Programming - Ch 16.7-16.11
- Work on Ch 16 Exercises
Day 3
- Finish Object Oriented Programming - Rest of Ch 16. However, you can skim 16.13 and skip 16.17 entirely if you want to. You should be aware of what classes look like when implemented in modules, but your assignments will all use .h/.cpp file implementations.
- Start the assignment
Day 4
- Do the Local Build and Run Assignment
- If you did not take CS161 here, also see the Review section.
Object Oriented Programming
Chapter 16 covers the basics of Object Oriented Programming (OOP).
The book covers implementing classes in a single module file (16.13) and in a .h/.cpp file pair (16.12). You can just skip 16.13 and focus on 16.12, since that is how you will be implementing classes in your assignments. (If you are not familiar with the difference, see Chapter 6 of the book.)
After you are through section 16.5 watch this video on using the debugger to inspect objects:
When you get to Ch 16.12, watch this video that shows what a class split into .h/.cpp files looks like in VSCode:
These other optional videos review key concepts from the chapter:
Big picture overview of OOP:
Basics of OOP (16.1-16.5):
Constructors (16.7):
Separation of Interface and Implementation (16.8):
UML (16.10):
Encapsulation (16.11):
Local Build and Run
Although GitHub Codespaces is a great environment for development, you should also be able to build and run your C++ programs on your local machine.
This week you have a mini assignment to demonstrate that you can build and run a simple C++ program locally on your machine. It requires taking a screenshot of your desktop, with VSCode (running locally, not in a Codespace) open with a C++ project loaded, and a terminal window showing the program being built and run. This video shows you how to do that:
Review
If you did not take CS161 here, read Chapter 5.11 on Doxygen style comments. Then watch this video to learn how to easily write doxygen comments in VS Code:
You should also review how to use the Combo Project Project Template:
And, if you don't know how to use the debugger in VSCode to step into and out of function calls, check out this video: