From the course: Advanced Design Patterns: Design Principles

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Loose coupling

Loose coupling

- [Instructor] We're now going to talk about the loose coupling principle, which says to strive for loosely coupled designs between objects that interact. As a quick definition, loose coupling occurs when a component has little knowledge about another component. The opposite of loose coupling is tight coupling which typically means that components are too dependent on each other. Here's another way to think about coupling. If we consider two classes, you could say they're tightly coupled when changes to one affects the other. We want classes to be uncoupled so they can still work with one another but we can change and vary them independently. We might even want to take one of the classes and totally replace it with a new class. And if things are loosely coupled then they shouldn't break. Because loose coupling naturally reduces the dependency between the components and our design, keeping designs loosely coupled helps us…

Contents