Lessons - 3003

C++

Unit 1: Entry-Level / Review / Tutorials

Week 1 8/23-25 Essentials

Course overview, Relevant programming environments and tools, especially in the context of software engineering

Week 2 8/30-9/1 Basics Review

Programming Concepts and API / frameworks / libraries / packages

  • Learning Outcomes

    • the difference between machine and high-level languages;

    • the machine code and compilation;

    • variables, integers, characters;

    • comments;

    • the basics of flow control;

    • dealing with streams and basic I/O operations;

    • writing simple programs.

  • Discussion / Mindfulness

  • OpenEDG

    • Part 1 - Module 1. Introduction to computer programming

      • Topics

        • 1.1 Different languages for different purposes

        • 1.2 Your first program

        • 1.3 Integer values, integer variables and comments

        • 1.4 Numbers and their operators

        • 1.5 Other kind of data: characters

        • 1.6 Flow control: how to make simple decisions?

        • 1.7 Connecting with the real world: input and output

      • Assignments

        • Module 1 Quiz

        • Module 1 Test

  • Exam Topics

    • Absolute basics

      • machine and high-level programming languages, compilation process,

      • obtaining the machine code: compilation process,

      • writing simple programs,

      • variables,

      • integers: values, literals, operators,

      • characters: values, literals, operators,

      • dealing with streams and basic input/output operations

  • Tutorial / Practice Activity

  • Readings

    • Chapter 1 C++ Basics

    • Chapter 2 C++ Basics: Functions and Files

    • Chapter 3 Debugging C++ Programs

    • Chapter 4 Fundamental Data Types

    • Chapter 5 Operators

  • Resources

  • Lesson

    • Grit and Growth Mindset

    • OpenEDG and Reading Review

      • Poll

      • A namespace is an abstract container or environment created to hold a logical grouping of unique entities (blocks). A namespace is a region that allows you to declare names inside of it for the purpose of disambiguation. The namespace provides a scope (called namespace scope) to the names declared inside of it -- which simply means that any name declared inside the namespace won’t be mistaken for identical names in other scopes.

      • Avoid using directives (such as using namespace std;) at the top of your program.

      • Chapter 1 Summary

      • Functions: arguments, parameters (image), scope illustration, benefits, ordering and prototypes,

      • Number systems, bits, bytes (Bit manipulation and converting between number systems next week)

      • Variables (descriptive names, declaration (close to use), assignment, initialization, concept, state diagram), data types, operators

      • Be sure to use your editor’s auto-formatting feature to keep your formatting consistent and make your code easier to read. Visual Studio: Hold down the Control key and then press K, followed by D.

      • Chapter 2 Summary

      • Errors and debugging

      • Chapter 3 Summary

      • Don't use magic numbers (numbers without context)

      • Chapter 4 Summary

      • mod, unary, conditional. logical

      • Chapter 5 Summary

    • Make a program - meal, tax, and tip

    • APIs

      • Resources above

    • Create a traditional Windows Desktop application (C++) or work on project or HackerRank

Week 3 9/8-13 - Flow control and data aggregates

More data types

  • Learning Outcomes

    • how to control the flow of the program;

    • more data types;

    • conditional instructions: if, else, switch;

    • loops and controlling the loop execution;

    • logic, bitwise and arithmetic operators;

    • vectors, multidimensional arrays;

    • declaring and initializing structures.

  • Discussion / Mindfulness

  • Benefits of mindfulness

Week 4 9/15-20 Pointers, functions and memory

Parameter passing, dereferencing

  • Learning Outcomes

    • designing, declaring, and invoking functions;

    • pointers;

    • different methods of passing parameters and their purpose;

    • default parameters;

    • inline functions;

    • overloaded functions;

    • sorting;

    • memory on demand.

  • Discussion / Mindfulness

  • OpenEDG

    • Part 1 - Module 3. Extending expressive power: pointers, functions and memory

      • Topics

        • 3.1 Pointers

        • 3.2 Pointers vs arrays

        • 3.3 Functions

        • 3.4 Declaring and defining functions

        • 3.5 Transferring data to and from functions

        • 3.6 Default parameters

        • 3.7 Inline functions

        • 3.8 Overloaded functions

        • 3.9 Sorting

        • 3.10 Memory on demand

      • Assignments

        • Module 3 Quiz

        • Module 3 Test

  • Exam Topics

    • Functions

      • functions,

      • declaring and invoking functions,

      • side effects,

      • different methods of passing parameters and their purpose,

      • default parameters,

      • inline functions,

      • overloaded functions.

  • Tutorial / Practice Activity

  • Readings

  • Resources

  • Lesson

    • Discussion

      • Gratitude, one positive thing, mindfulness

    • OpenEDG and Reading Review

      • functions

        • different methods of passing parameters (value, reference, address) and their purpose

        • default parameters, inline functions, overloaded functions

        • code

    • Review / Muddiest Point Clarification

    • OOP of the week: Make a class diagram with methods

    • Blazor

Week 5 9/22-27 Data: Arrays of pointers and Conversion

Strings intro

Week 6 9/29-10/4 Data

Strings as objects, namespaces, exceptions

  • Learning Outcomes

    • Integrate a class in a cpp file with private fields and public methods

  • Discussion / Mindfulness

  • OpenEDG

    • Part 1 - Module 4. Accessing various kinds of data cont.

      • Topics

        • 4.4 Strings - continued

        • 4.5 Strings - temporary summation

        • 4.6 Name spaces

      • Assignments

        • Module 4 Quiz

        • Module 4 Test

        • Course 1 Summary Test

  • Exam Topics

    • Accessing data and dealing with exceptions

      • string as an example of object: introducing methods and properties,

      • namespaces: using and declaring,

      • dealing with exceptions

  • Tutorial / Practice Activity

  • Readings

    • Chapter 22 std::string

    • Chapter 23 Input and Output (I/O)

  • Resources

  • Lesson

    • SA Updates - ShellHacks

    • Discussion Review (10 minutes)

    • Muddiest Point Clarification

      • HTML & CSS

      • IPO

      • Getters and setters (in OOP of the week)

    • OpenEDG and Reading Review (20 minutes)

    • Blazor + break time (60 minutes)

      • API example

        • In a Chrome tab signed in to Canvas -> three dots -> More tools -> Developer tools -> Console -> paste $.getJSON("/api/v1/courses", function(data) { console.log(data); });

    • Console application that writes to a file and reads from a file (20 minutes)

    • OOP of the week: private fields, public methods, review overload (15 minutes)

    • Work on Hackerrank exercises (20 minutes)

    • Plus Delta

Unit 2: Intermediate / Associate Level / Independent Project

Week 7 10/6-11 The essentials of OOP

Modularity (classes and packages)

  • Learning Outcomes

    • LO1. Design and implement a class. [Usage]

    • LO4. Compare and contrast (1) the procedural/functional approach (defining a function for each operation with the function body providing a case for each data variant) and (2) the object-oriented approach (defining a class for each data variant with the class definition providing a method for each operation). Understand both as defining a matrix of operations and variants. [Assessment]

  • Discussion / Mindfulness

  • OpenEDG

    • Part 2 - Module 1. The essentials of OOP

      • Topics

        • 1.1 The basic concepts of OOP;

        • 1.2 A stack: the procedural approach vs. OOP;

        • 1.3 The anatomy of classes;

  • Exam Topics

    • Fundamentals of the object-oriented approach

      • class

      • objects

      • class components

      • constructors

  • Tutorial / Practice Activity / Project

    • Project Planning

    • Integrate a class with a constructor in a header file

  • Readings

  • Resources

  • Lesson

    • Discussion Review

    • Tutorial Review: readme and comments

    • Plus Delta Review

    • Muddiest Point Clarification

    • OpenEDG and Reading Review

      • Subclasses / inheritance introduction

      • The long tail of the content vs. importance graph

      • Procedural vs object-oriented approach

        • A stack: the procedural approach vs. OOP

          • Code it and comment it

            • Class can contain full function definition or prototype

            • Put it in a header file

        • Briefly compare and contrast procedural vs. OOP in writing

    • OOP of the week: review overload, constructors and destructors

    • Project Planning

Week 8 10/13-18 The essentials of OOP

Encapsulation

Week 9 10/20-25 Inheritance

Class hierarchies

  • Learning Outcomes

    • LO2. Use subclassing to design simple class hierarchies that allow code to be reused for distinct subclasses. [Usage]

  • Discussion / Mindfulness

  • OpenEDG

    • Part 2 - Module 2. Inheritance

      • Topics

        • 2.1 Class hierarchies;

        • 2.2 Classes, inheritance, and type compatibility

  • Exam Topics

    • Class hierarchy

      • base class, superclass, subclass,

      • inheritance: how it works,

      • types of inheritance,

      • inheriting different class components,

      • multiple inheritance.

  • Tutorial / Practice Activity / Project

    • Integrate inheritance

  • Readings

  • Resources

  • Lesson

Week 10 10/27-11/1 Polymorphism

Virtual functions

  • Learning Outcomes

    • LO3. Correctly reason about control flow in a program using dynamic dispatch. [Usage]

    • LO5. Explain the relationship between object-oriented inheritance (code-sharing and overriding) and subtyping (the idea of a subtype being usable in a context that expects the supertype). [Familiarity]

  • Discussion / Mindfulness

  • OpenEDG

    • Part 2 - Module 2. Inheritance cont.

      • Topics

        • 2.3 Polymorphism and virtual methods;

        • 2.4 Objects as parameters, and dynamic casting;

        • 2.5 Various supplements;

        • 2.6 The const keyword;

        • 2.7 Friendship in the C++ world.

      • Assignments

        • Module 2 Quiz

        • Module 2 Test

  • Exam Topics

    • More on classes

      • polymorphism: the notion and the purpose,

      • virtual methods: declaration and usage,

      • inheriting virtual methods,

      • abstraction and abstract classes.

  • Tutorial / Practice Activity / Project

    • Milestone 1

    • Integrate polymorphism

  • Readings

  • Resources

  • Lesson

    • Discussion Review

    • OpenEDG and Reading Review

      • Overriding

        • override specifier - if the function does not override a base class function, the compiler will flag the function as an error

        • final specifier - not overridable

      • Downcasting: Treat a pointer to a superclass as a pointer to its subclass.

      • Uppercasting / Upcasting: Treat a pointer to a subclass as a pointer to its superclass.

      • Polymorphism

        • A method to redefine the behaviour of a superclass without touching its implementation.

        • The one and same class may show many (“poly” – like in “polygamy”) forms (“morphs”) not defined by the class itself, but by its subclasses

        • The ability to realize class behaviour in multiple ways

        • Pet Cat Dog example

      • virtual

        • a special type of function that, when called, resolves to the most-derived version of the function that exists between the base and derived class - learncpp

        • perhaps the biggest benefit of virtual functions is the ability to structure code in such a way that newly derived classes will automatically work with old code without modification!

        • Late binding or Dynamic linkage or Dynamic binding - function call is resolved during runtime, the compiler determines the type of object at runtime, and then binds the function call, similar concept to...

        • dynamic dispatch - the process of selecting which implementation of a polymorphic method to call at run time.

        • Pet Cat Dog example

        • A pure virtual function or abstract function - exists only to be overridden, assigned 0

          • A class containing a pure virtual function cannot be used to declare the objects of its own, such classes are known as abstract base classes, they exist only to be derived.

          • Classes derived from abstract base classes are also abstract until they override the pure virtual function.

          • Can actually have a body, which could be called from derived class

        • An object of a derived type can be sent as an argument to a function expecting a parameter of the base type.

        • The dynamic_cast operator - If the conversion of the object to the type is possible, then the result is a new pointer which is fully usable.

      • "const" - unalterable

        • with variables - must be initialized, can't be reassigned

        • with aggregates - read-only

        • with pointers - pointers can't change but the entities pointed to may be modified with no restrictions, int * const iptr

        • pointers to constants - pointers can change but the entities pointed to can't, const int *iptr

        • with pointers to constants - const int * const iptr

        • with fields - unalterable during the object's life, must be initialized in initialization list

        • with objects - mustn’t be modified during its life

        • with methods - promise that they won't modify state of object

      • "friend" review

      • Interface classes

        • no member variables and all pure virtual functions

      • Overriding <<

    • Practice question #7

Week 11 11/3-8 Exceptions

Error handling

  • Learning Outcomes


  • Discussion / Mindfulness

  • OpenEDG

    • Part 2 - Module 3. Exceptions

      • Topics

        • 3.1 Introduction to exceptions;

        • 3.2 The throw statement in detail;

        • 3.3 Exception categories;

        • 3.4 Catching exceptions

  • Exam Topics

    • Exceptions - dealing with expected and unexpected problems

      • what is an exception,

      • catching and throwing exceptions,

      • different classes and hierarchy of exceptions,

      • defining your own exceptions.

  • Tutorial / Practice Activity / Project

    • Integrate exception handling

  • Readings

  • Resources

  • Lesson

    • Discussion Review

    • OpenEDG and Reading Review

      • a throw statement is used to signal that an exception or error case has occurred (think of throwing a penalty flag)

      • division by zero :(

      • Exceptions and inheritance - order of catch matters

      • std::exception is a small interface class

      • scope in try

      • Exception handling is best used when all of the following are true:

        • The error being handled is likely to occur only infrequently.

        • The error is serious and execution could not continue otherwise.

        • The error cannot be handled at the place where it occurs.

        • There isn’t a good alternative way to return an error code back to the caller.

    • Exception handling in C++ vs Java

      • In C++, all types (including primitive and pointer) can be thrown as exception. But in Java only throwable objects (Throwable objects are instances of any subclass of the Throwable class) can be thrown as exception.

      • C++ has "catch all" (...). In Java, we can catch class Exception to catch all kind of exceptions.

      • In Java, there is a block called finally that is always executed after the try-catch block. This block can be used to do cleanup work. There is no such block in C++.

      • In C++, all exceptions are unchecked. In Java, there are two types of exceptions – checked and unchecked.

      • In Java finding and handling the exception is easier than in C++.

    • Visual Studio try tab

    • If your function may not throw, declare it noexcept

    • Practice question #16, 17, 18, 19 class diagrams and state / memory diagram

Week 12 11/10-15 Generics / Templates

  • Learning Outcomes

    • LO7. Define and use iterators and other operations on aggregates, including operations that take functions as arguments. [Usage]

  • Discussion / Mindfulness

  • OpenEDG

    • Part 2 - Module 3. Exceptions

      • Topics

        • 3.5 Exceptions in action

      • Assignments

        • Module 3 Quiz

        • Module 3 Test

  • Exam Topics

    • None

  • Tutorial / Practice Activity / Project

    • Add a template.

    • Define and use iterators and other operations on aggregates, including operations that take functions as arguments.

  • Readings

  • Resources

  • Lesson

    • Discussion Review

    • OpenEDG and Reading Review

      • A template is essentially a stencil for creating functions or classes.

      • Templates can work with types that didn’t even exist when the template was written. This helps make template code both flexible and future proof!

      • template parameters

      • template argument deduction: the compiler deduces the type that should be used from the argument types

      • template types are sometimes called generic types

      • A good rule of thumb is to create normal functions at first, and then convert them into function templates if you find you need an overload for different parameter types.

      • C++20 introduces a new use of the auto keyword: When the auto keyword is used as a parameter type in a normal function, the compiler will automatically convert the function into a function template with each auto parameter becoming an independent template type parameter. This method for creating a function template is called an abbreviated function template.

      • Template classes are ideal for implementing container classes

      • you should understand what std::vector<int> means now

      • put all of your template class code in the header file or rename cpp inl

    • Passing a function as a parameter in C++ geeksforgeeks

Week 13 11/17-22 Operators

Pointer Arithmetic

Week 14 11/29-12/1 Enumerated types

Unit 3: Wrap Up

Week 15 12/6-8 Wrap up