Inheritance Refactor
Here you will learn about Prototypical Inheritance in JavaScript. Along the way you will learn a few common inheritance design patterns and get more experience with dependency injection.
Index
Learning Objectives
- Inheritance
- Inheritance design patterns
Specifications
To witness the power of inheritance we will build an application that allows users to interact with multiple data types. You will build a zoo application that allows a user to keep track of 3 types of animal:
- kangaroos
- orcas
- swallows
Each animal will be stored in a separate model object.
A Zookeeper can ...
- Feed an animal
- Eat an animal
- Rename an animal
- Marry two animals
- Buy more animals
- Sell animals
Project:
- Study this markdown to explore how Prototypes work in JS
- Create a planning chart for your application
- For each story:
- Write tests for each module
- Build the application with the simplest model
- For each Inheritance Exercise
- Build the model
- Build an app that uses your new model
- Do you need to write new tests?
- Code reviews!
Challenge:
- Re-implement the functionality for "super" and "extends" from ES6 Classes in ES5 using prototypes.
Resources
- Prototype Markdown
- "Objects" list in General Resources
- Great code to study
- You Don't Know JS - prototypes
- Closures - You Don't Know JS
- 5 ways to make objects