Program to an interface

One of the good design principles is to program to an interface. What does programming to an interface mean? An easy way to explain this is to think of the domain model of a system to be defined in terms of (Java) interfaces. These definitions are like vocabulary of the system as these do not contain implementation but just declarations. The system using the domain works against the interface and does not know what is going to be the implementation until run time. A factory, a broker or a container could actually help get an implementation during runtime. The key advantage is the layer that uses the interface is loosely coupled with implementation and there could be several implementations of the domain model that suits specific situations/needs. What other advantages does programming to the interface bring? And why not an abstract class instead of interface? This, year old interview “A Conversation with Erich Gamma” by Bill Venners best answers these questions.

Blink this Program to an interface at blinklist.com    Bookmark Program to an interface at blogmarks    Bookmark Program to an interface at del.icio.us    Digg Program to an interface at Digg.com    Fark Program to an interface at Fark.com    Bookmark Program to an interface at Furl.net    Bookmark Program to an interface at NewsVine    Bookmark Program to an interface at reddit.com    Bookmark Program to an interface at Simpy.com    Bookmark Program to an interface at Spurl.net    Bookmark Program to an interface with wists    Bookmark Program to an interface at YahooMyWeb

      Cosmos

Leave a Comment

authimage


Creative Commons License  This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.