Skip to content

Files

Latest commit

2990ed2 · Jun 9, 2020

History

History
89 lines (81 loc) · 2.78 KB

base-class.md

File metadata and controls

89 lines (81 loc) · 2.78 KB

Base Class

A base class is a class:

  • that has been added to provide shared functionality to child classes, and
  • that is not intended to exist as a standalone, instantiable type

For example:

// `ValueObject` is a base class
class ValueObject<T> {
    protected value T;

    protected constructor(input: T) {
        this.value = T;
    }

    public valueOf(): T {
        return this.value;
    }
}

// `MediaType` is a child class
class MediaType extends ValueObject<string> {
    public constructor(input: string) {
        mustBeMediaTypeData(input);
        super(input);
    }
}