Abstracts

Developed with
QA

Contents

keyboard_tab
Typescript
1
Inheritance
PREVIEW1m 24s
2
Access Modifiers
PREVIEW4m 17s
4
Abstracts
1m 52s

The course is part of this learning path

Typescript: Zero to Hero
course-steps
8
certification
2
play-arrow
Start course
Overview
DifficultyBeginner
Duration13m
Students66
Ratings
5/5
starstarstarstarstar

Description

This module introduces you to Classes and how to use them in TypeScript.

Learning Objectives

The objectives of this module are to provide you with and understanding of:

  • What classes are
  • How to use inheritance in TypeScript Classes
  • How to use Access Modifiers
  • How to use Abstracts
  • How to use Structural Typing

Intended Audience

This learning path is aimed at all who wish to learn how to use TypeScript

Prerequisites

It is essential you understand the face of contemporary web development to attend this course. You should have a good working knowledge of Javascript. Please note: Before attending this class delegates must have a Microsoft account (signing up one is free).


Feedback

We welcome all feedback and suggestions - please contact us at qa.elearningadmin@qa.com to let us know what you think.

Transcript

Abstract classes allow us to create base classes from which other classes may be derived. They've been part of JavaScript since years 2015. Abstract classes cannot be instantiated themselves, but they can provide names for the required class variables and functions. Functions can have a concrete implementation, or they can be made abstract. If that's the case, then the class using the abstract as a base must provide the implementation for the function. A good example for an abstract class is a shape class. All shapes, it could be argued, will have a name, a number of sides and an area. But we'd never want to create an instance of an arbitrary shape. We have a constructor that defines the name, number of sides and a value for the area of any class that uses this as a base. There's an abstract get function called calc area. This has no implementation as each shape will have its own method of calculating its area. It defines a concrete implementation of a print shape info method. Beneath that, we have a circle class that extends the shape class, having its own property of radius. An implementation of get calc area is provided, that calculates sets and returns the area. On the right hand side of the screen we have a triangle class that does the same thing, but uses a different implementation for calc area. On line 50, we try and instantiate the shape class. We get the error I show. we cannot create an instance of an abstract class. The instantiations of the circle and triangle classes are fruitful. And we can use calc area and the print shape info method.

Lectures

About the Author
Students3028
Labs8
Courses29
Learning paths6

An outstanding trainer in software development with more than 15 years experience as a Corporate and Apprentice Trainer, ICT Teacher and Head of Department, with a passion for technology and its uses. Continuing to develop existing and new skills and courses, primarily in web design using PHP, JavaScript, HTML, CSS and SQL but also OOP (Java), programming foundations (Using Python), DevOps (Git, CI/CD, etc) and Agile/Scrum. Practically minded, a quick learner and a problem solver with an attention to detail to ensure high quality outcomes.

Covered Topics