← Back to Roadmap

Abstraction

Medium

In plain terms

Abstraction is about reducing complexity by hiding details. You expose a simple way to do something without forcing the caller to understand how it works inside. For example, "start the car" is an abstraction—you do not need to know about fuel injection or spark plugs.

In code, abstract classes or interfaces define a contract (what methods exist) without implementing every detail. Concrete classes then fill in the implementation. Abstraction lets you think at a higher level and swap implementations without changing the code that uses them.

What you need to know

  • Hide complexity, show essentials
  • Interfaces and abstract types
  • Work at a higher level

Example

Code is language-agnostic in spirit; adapt the idea to your language:

// Abstraction: simple interface
class PaymentProcessor {
  process(amount) {
    this.validate(amount);
    this.charge(amount);
    this.log(amount);
  }
  // Subclasses implement validate, charge, log
}
// Caller only uses process() - details hidden

Why this matters

Abstraction is key in system design and API design. Interviewers ask how you hide complexity and design interfaces that stay stable while implementations change.

How it connects

Abstraction is achieved via interfaces/abstract classes—the same idea behind Dependency Inversion (depend on abstractions). It enables polymorphism: callers depend on the abstract type, not concrete classes.

Interview focus

Be ready to explain these; they come up often.

  • Definition: hide complexity; expose only what is necessary for the caller.
  • Tools: abstract classes, interfaces; in JS: duck typing and clear public APIs.
  • Real-world analogy: drive a car without knowing engine internals.

Learn more

Dive deeper with these resources: