What Does It Mean to Program to an Interface
Simple: “Coding to Interfaces, Not Implementation. ” Coding to Interfaces Is a Technique to Write Classes Based on an Interface; Interface That Defines What...
Simple: “Coding to interfaces, not implementation.” Coding to interfaces is a technique to write classes based on an interface; interface that defines what the behavior of the object should be. It involves creating an interface first, defining its methods and then creating the actual class with the implementation.
What is programming to an interface?
Simple: “Coding to interfaces, not implementation.” Coding to interfaces is a technique to write classes based on an interface; interface that defines what the behavior of the object should be. It involves creating an interface first, defining its methods and then creating the actual class with the implementation.
Must Read
Should you always program to an interface?
Sylvia wrote a great summary why you should use it: Interfaces make your code less brittle. If implementations change, your code will still work—as long as the interface doesn’t change. However, there is an urging question, when programming against an interface pattern should be used.