From the course: Design Patterns: Creational

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Design principles and Abstract Factory

Design principles and Abstract Factory

From the course: Design Patterns: Creational

Start my 1-month free trial

Design principles and Abstract Factory

- [Narrator] An abstract factory gives us an interface for creating a family of products. By writing code that uses this interface, we decouple our code from the actual factory that creates the product. That means that we can implement a variety of factories that produce products meant for different contexts. In our example, that's different user roles. This is a good illustration of the loose coupling principle, which says that we should strive for loosely coupled designs between objects that interact, meaning that we could substitute different factories to get different behaviors like different views or a different set of functions, depending on the role of the user. And like the factory method pattern, the abstract factory pattern adheres to the principles: encapsulate what varies, program to the interface not the implementation, and depend on abstractions.

Contents