The Code You Need

A quick review of exactly the code this course uses, in all five languages. Learners who know it can take the chapter check first and skip ahead.

Updated

Loops, Methods and Lists

  1. Loops and Methods, Five Ways (Novice): A quick review of the loops and methods this course uses, in all five languages, with a snack stand as the example: a for loop, a while loop, a for-each loop, and a method that takes values and returns one.
  2. Arrays and Lists (Novice): A review of the two ways each language keeps items in a row: a fixed-size array and a list that grows, reading and changing an item by its index, and when to use each.

Objects

  1. Classes and Objects (Apprentice): A review of classes and objects in all five languages: a Snack class with fields, a constructor and methods, objects made from it, and the classic shape of a Java program you'll see in textbooks.
  2. Generics: a Box for Any Type (Apprentice): How C#, Java and TypeScript write one class that works for any type of item, read aloud as "a list of snacks", and why Python and JavaScript don't need the label.
  3. References: Two Names, One Object (Apprentice): Why copying a variable that holds an object copies only the note that says where it is, so two names can change one object; how to make a real copy; and null, None and undefined, the note that points at nothing.

Exercise: The Snack Inventory

  1. Exercise: The Snack Inventory (Apprentice): Finish a snack stand's inventory code in your language: a Snack class's value method, then find a snack by name, add up the stock's value, and list what's running low, using loops, lists, classes and references.