Book Image

TypeScript Essentials

By : Christopher Nance
Book Image

TypeScript Essentials

By: Christopher Nance

Overview of this book

Table of Contents (15 chapters)

Abstraction


Abstraction is an incredibly powerful concept in object-oriented development. It encompasses the idea of hiding specific implementation details while providing the high-level definition of what should be implemented. In the previous example, we saw a very basic case of abstraction. The IActivator interface creates the abstraction layer needed to handle the concept of activating the application. The LocalActivator and ServerActivator types are concrete implementations of this abstraction. In other programming languages such as C#, classes are able to declare specific members as abstract. This forces any subclasses of the base type to provide a concrete implementation of that member. In the following code segment, you will see a C# example of this:

public abstract class AbstractBaseClass
{
    protected bool isActive = false;
    public AbstractBaseClass()
    {
    }
    public abstract bool CheckStatus();
}
public class ConcreteClass : AbstractBaseClass
{
    public ConcreteClass...