Programming to an interface is saying, "I need this functionality and I don't care where it comes from."
Consider (in Java), the List
interface versus the ArrayList
and LinkedList
concrete classes. If all I care about is that I have a data structure containing multiple data items that I should access via iteration, I'd pick a List
(and that's 99% of the time). If I know that I need constant-time insert/delete from either end of the list, I might pick the LinkedList
concrete implementation (or more likely, use the Queue interface). If I know I need random access by index, I'd pick the ArrayList
concrete class.