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.
Program to interfaces
From the course: Advanced Design Patterns: Design Principles
Program to interfaces
- [Instructor] Program to Interfaces, Not Implementations. This is a design principle that guides us to make use of abstract types, not concrete ones to allow our designs to be more flexible and maintainable. Program to an interface really means program to a super type. If you're, say, a Java programmer, don't assume we're talking about the interface construct, but instead think more generally. We're really talking about, again, the concept of a super type, whether that be an abstract class or a Java interface or some similar language construct. The point is to be able to exploit polymorphism by programming to a super type so that your actual runtime object isn't locked into your code. To understand this better, let's look at an example. Let's say your have a killer web system that you're developing and it depends on a commercial database. Here we have a killer web system class and it has a property, DB, meant to be set…
Contents
-
-
-
Encapsulate what varies5m 41s
-
(Locked)
Favor composition over inheritance4m 5s
-
(Locked)
Loose coupling4m 42s
-
(Locked)
Program to interfaces4m 47s
-
(Locked)
Single responsibility principle5m 5s
-
(Locked)
Open-closed principle3m 56s
-
(Locked)
Liskov's substitution principle5m 37s
-
(Locked)
Interface segregation principle5m 29s
-
(Locked)
Dependency inversion principle4m 49s
-
-