Principle
// Good - uses interface as type
List<Subscriber> subscribers = new Vector<Subscriber>();
One caveat
If the original implementation offered some special functionality not required by the general contract of the interface and the code depended on that functionality, then it is critical that the new implementation provide the same functionality.
Examples:
Summary
In practice, it depends whether a given object has an appropriate interface. If it does, your program will be more flexible if you use the interface to refer to the object; if not, just use the least specific class in the class hierarchy that provides the required functionality.
Effective Java 52 Refer to objects by their interfaces,布布扣,bubuko.com
Effective Java 52 Refer to objects by their interfaces
原文:http://www.cnblogs.com/haokaibo/p/refer-to-objects-by-their-interfaces.html