Week 1 - Class Overview and 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
The recommended schedule represents a MINIMUM pace in the course. The summer term is 3 weeks shorter than the regular terms (8 weeks instead of 10 weeks + finals week). You will need to put in substantial work each week to get through the material.
If you intend on doing significant work during weekends, you should be working AHEAD on the weekend, not trying to catch up (i.e. working on week 1 on the weekend preceding it, not the weekend after it).
Except for the final exam, you are completely free to work ahead as far as you like. Use that flexibility to buy yourself "time off" for anything you have planned and to give yourself a buffer for anything unplanned.
Recommended Schedule
Monday
- Review Syllabus and Course Tips
- OOP Intro
- Setup VSCode at home. Update Project Templates and plugins.
- Take the background survey in elearn
- CPPLab - Objects Basics - Use
Tuesday
- Headers and information hiding
- CPPLab - Objects Basics - Creation
- Documentation, and UML
Wednesday
- Unit Testing In CS162
- Start assignment 1
Thursday
Friday
If needed, review working from the command line:
And/or move on to week 2!
Setup
Review the Syllabus in elearn. Then do the Background survey and Class Policies Quiz in eLearn.
You need to get VSCode set up using these instructions.
If you already had VSCode and a compiler set up from CS161, you should grab new copies of the VSCode project templates. We periodically make minor updates and improvements to them: VSCode Project Templates
Because we just switched to using VSCode, here are some quick tips on using it to work with projects and files:
If you took CS161 in Java (or did AP CS A), you need to learn the basics of C++. Check out this C++ Crash Course for AP CS students.
Some of the videos in this course were made using a different IDE (QTCreator). It functions basically the same as VSCode. If you can't figure out how to do something you see in VSCode, please raise the issue in the discussion forum.
For any video, you can click in the lower right corner to watch on YouTube. You can then use the settings icon there (Gear symbol at bottom of video) to watch at higher quality. Doing so can make a big difference when trying to read code examples.
OOP Basics
The history of modern programming is a quest for abstractions and structure that can be added to assembly code to make programmers more productive and less error-prone. At some point, our code gets boiled down to machine instructions we could have written directly in assembly… but higher-level languages allow us to more succinctly express ourselves and provide structure and limitations that prevent us from writing unintelligible and unmaintainable code.
Object Oriented Programming is a methodology for structuring programs that aims to make parts of a system accessible to each other through high-level abstractions—so you don't have to know the ugly details of how a window paints itself to the screen, just that you can ask it to repaint itself by saying window.repaint(). It is the methodology of choice for most large projects involving large teams of developers all working on different parts of a system. There is nothing we can write using OOP we could not write without it, but it does make some jobs much easier.
Read Ch 9.1-9.5 and watch these videos:
Do the Objects Basics - Use CPPLab.
If you are not familiar with CPPLab, watch the video below. We will use it to get some of the small-scale practice required to really understand what you are doing. Your username is the same as your my.chemeketa gmail username. Your starting password is "changeme"; you can change it on the login screen.
Headers and Information Hiding
Read Ch 9.6-9.7 and watch these videos:
Do the Objects Basics - Creation CPPLab.
Documentation and UML
Read 9.10-9.11 and watch these videos:
This first video shows QTCreator, but VSCode does the same trick. Type /** on the line above a function and hit enter.
Unit Testing
Unit Testing Review
If you did not take CS161 here, begin by reviewing these three videos about unit testing. Otherwise, feel free to skip them.
Unit Testing - CS162
In CS162 there are some small differences in how we will do unit testing. This video talks about them:
The UnitTesting Guide has step-by-step instructions for setting up unit testing projects refer to it any time you need to set up a project.
Intro to Source Control & Github
Source control is going to take you a while to master—don't worry about doing it all this week. Watch the videos and at least work through part 1 of this Git Tutorial, which will walk you through making your own clone of the CS162 repository.
These videos introduce the basic idea behind source control, what git is, and how we will use it:
None of these are required reading, but if you want to learn more about git, here are some good references:
Git Extra Info
Visual Git Reference
Learn Git Branching
Pro Git Book
Working on the Command Line - Review
In CS161 we learned how to use the command line. If you don't remember how to navigate on the command line and how to build your code by hand and run it, you should review this topic.
This Command Line Guide provides detailed instructions for how to open a command prompt, set up the path, navigate, and use g++. Using a QtCreator project, try building and running the code from the command prompt as shown in the video.
Assignment
Before you tackle this week's assignment, check out this video that reviews two other sample classes. The SimpleString shows a class that manages an array which is something you need to do in your first assignment.
Extra Info
OOP Introduction
New to object-oriented programming? Having trouble seperating the details from the big picture? Try reading Don't fear the OOP.
Unit Testing & Test Driven Development
- 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.
- 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)