Loading video player…

Inheritance, Composition and JavaScript's Types (Overview)

Welcome to Inheritance, Composition and JavaScript’s Types. As a program grows, three questions keep coming up. When is one object a kind of another? When should it be built from parts instead? And what about values that arrive as text when you need a number? The first is a question of inheritance, the second of composition.

You’ll answer them while you build a lending tracker for the Elm Street toy library, which volunteers run from a garage. All toys are lent alike, but a building set counts its bricks, and a dress-up box has a size. The tracker lends the wooden train set to Leo Okonkwo, and when Maya Chen asks for it, it refuses and says why. The train set is out with Leo.

What You’ll Learn

By the end of this course, you’ll be able to:

  • Design a small family of classes.
  • Choose composition where inheritance doesn’t fit.
  • Define custom errors.
  • Convert values explicitly where they enter a program.
  • Build a program from a brief, then plan one of your own.

A building set is a kind of toy. A lending desk isn’t a toy, so you build it from parts. You turn a typed age into a number. The project’s tests check your code, and the steps are yours.

Before You Start

You need to know classes, modules, and throwing and catching errors, each recapped where it’s used. You’ll also need a current version of Node.js and a terminal.

How the Course Works

The text lessons have you build the tracker in your editor, and two videos look behind the scenes. Each section ends with an exercise, tested on the site. The project ends with two mentor reviews, one of the toy library and one of a program of your own, and a quiz closes the course.

Next, in Build a Subclass With extends, you’ll write the first kind of toy.

Download

Course Slides (.pdf)

488.8 KB
Download

Sample Code (.zip)

20.2 KB

Become a Member to join the conversation.