Course contentsShow
← Software Engineering
Lesson 222 of 1,9336. SOLID PrinciplesFree lesson

Abstractions Should Not Depend on Details

Learning why abstractions must be stable and independent of concrete implementation details.

Abstractions Should Not Depend on Details

You'll learn why keeping abstractions independent from concrete implementations makes your software stable and maintainable.

The Problem with Dependencies on Details

When you create an abstraction (like an interface or abstract class), it should define what needs to happen—not how it happens. If your abstraction references specific implementation details, you've created a fragile design that breaks whenever those details change.

Think of abstractions as contracts or blueprints. A blueprint for "a door" shouldn't specify "must be made of oak wood with brass hinges from Home Depot." That would make the blueprint dependent on specific materials and suppliers. Instead, it should just define what a door does: "provides entry and exit, can be opened and closed."

Why Abstractions Must Stay Stable

Abstractions exist at a higher level of thinking. They represent concepts that rarely change (like "saving data" or "sending notifications"). Implementation details change frequently (file formats, database vendors, messaging protocols). If your abstraction depends on these details, it becomes unstable and forces changes to ripple throughout your system.

When abstractions stay independent of details, you can swap implementations freely. Your "data storage" abstraction shouldn't care whether you use files, databases, or cloud storage—that's a detail.

The Right Direction

Remember from dependency direction: high-level concepts (abstractions) should be stable. Low-level details should depend on abstractions, never the reverse. The abstraction defines the rules; the concrete implementation follows them.

Key Takeaway: Abstractions define stable contracts based on what needs to happen; they must never reference or depend on the how of concrete implementations, ensuring your high-level design remains stable even as low-level details change.