Improving TodoIt with Classes and Interfaces

In this chapter, we will improve our TodoIt application by making use of classes and interfaces, which will improve the code quality and make the application easily extendable and more maintainable.

By going from an almost purely imperative programming approach to a more object-oriented one, our code will convey more meaning, and we will be able to isolate specific concerns better.

First of all, we will briefly review the major object-oriented programming principles, including what classes and interfaces are and why they're beneficial when building applications, from the smallest to the largest ones.

We will go on to define the domain model of the TodoIt application using UML (short for Unified Modeling Language, for more information, see https://www.uml.org).

Then, we'll implement the code of our domain model, when you will be able to write your first classes and discover how to define constructors, accessors, default values, and so on. By introducing interfaces in the code base, we will be able to touch on why they're important and why composition is generally preferred over inheritance.

Through practice, you will also see how TypeScript classes/interfaces and JavaScript classes/objects relate to each other. Finally, we will also see how to leverage structural typing to improve our code.

Let's have a look at the important topics we are going to cover in this chapter:

  • Basic object-oriented programming (OOP) concepts and nomenclature
  • TypeScript concepts
  • The relation between TypeScript classes, interfaces, and JavaScript objects/classes
  • The UML and class diagrams
  • Object-oriented design
  • The single responsibility principle (SRP) and SOLID design concepts
  • The Law of Demeter (LoD)
  • Open/closed principle
  • Fluent API
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.123.120