This chapter covers:
- How class inheritance works
- Why and when to use abstract classes
- How interfaces can force a class to have methods with known signatures without worrying about implementation details
- What "programming to interfaces" means
In chapter 2, we introduced classes and interfaces for creating custom types. In this chapter, we’ll continue learning classes and interfaces from the object-oriented programming (OOP) perspective. OOP is a programming style where your programs are about handling objects rather than being a composition of actions (think functions). Of course, some of these functions would create objects as well, but in OOP, objects are the center of the universe.
Developers who work with object-oriented languages use interfaces as a way to enforce certain API on classes. Also, you can often hear the phrase "program to interfaces" in conversations of programmers. In this chapter, we’ll explain what it means. In short, this chapter is a whirlwind tour of OOP using TypeScript.
Let’s recap what we know about TypeScript classes from chapter 2: