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);
}
}