Course contentsShow
← Software Engineering
Lesson 189 of 1,9335. Software Design PrinciplesFree lesson

Dependency Direction and Stability

Organizing dependencies so stable, high-level components don't depend on volatile, low-level details.

Dependency Direction and Stability

You'll learn how to structure dependencies so that stable, high-level components don't depend on volatile, low-level details.

The Core Idea

In software, some components change frequently (volatile), while others rarely change (stable). Dependency direction refers to which components depend on which others. The key principle: dependencies should point toward stability. Stable components should not depend on volatile ones, because when the volatile part changes, everything depending on it must change too.

Think of it like a building's foundation. The foundation (stable) supports the walls and roof (more volatile—you might renovate them). You'd never build a foundation that depends on the specific paint color of your walls. If you did, changing the paint would require rebuilding the foundation!

High-Level vs. Low-Level

High-level components contain core business logic and policies—the essential "what" of your system. These should be stable because they represent fundamental truths about your domain.

Low-level components handle implementation details—databases, UI frameworks, file systems—the "how." These change more frequently as technology evolves.

Traditional programming often creates dependencies that point the wrong way: business logic depending on specific databases or UI frameworks. This makes the stable core brittle.

Organizing for Stability

The solution: make low-level details depend on high-level abstractions. Your core business logic defines interfaces (remember: "Program to an Interface, Not an Implementation"), and the volatile details implement those interfaces. Now when implementation details change, your stable core remains untouched.

This aligns with earlier principles: stable interfaces provide implementation flexibility, and abstraction hides volatile details behind stable contracts.

Key Takeaway: Dependencies should flow toward stability—stable, high-level components should not depend on volatile, low-level details; instead, details should depend on stable abstractions.