"Abstract is a class that says 'you must extend me to use me.'"
What abstract does
abstract class Base { ... } declares a class that can't be instantiated directly. new Base() is a compile error — you have to extend it first. Abstract classes are templates: they describe shared structure and partial implementation, leaving specifics for subclasses.
An abstract class can declare abstract method(): T — a method signature with no body. Concrete subclasses must implement it. This is the type-system version of 'these are the methods you must provide,' enforced at compile time.
When to reach for abstract
Abstract classes earn their keep when:
- You have shared state and behavior across a family of types.
- Subclasses must implement specific methods but reuse most of the rest.
- You want to forbid direct instantiation of the base.
If you only need a contract (no shared state, no shared implementation), use an interface — it's lighter. Abstract classes are for when interface alone isn't enough.
Abstract vs interface
Both describe contracts. Abstract classes also provide implementation. The rule of thumb: if you need to share code, use abstract. If you only need to share the shape, use interface. Many codebases use both — an interface describes the contract, and an abstract class implements common behavior for that contract.