The Artima Developer Community
Sponsored Link

Design Forum
Programming to an interface

2 replies on 1 page. Most recent reply: Nov 10, 2008 8:17 PM by Rajiv Narula

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Edward Lynn

Posts: 1
Nickname: edlynn
Registered: May, 2008

Programming to an interface Posted: May 12, 2008 6:18 AM
Reply to this message Reply
Advertisement
Hi, I know programming to an interface is best practice, but on a practical level i'm struggling to get my head around why sometimes. I'm creating a news section on our site, with 2 different types of news. They both implement a very similar set of methods, and so my thinking is that i should probably create a news interface, which internal_news and external_news implement.

That's fine, but on a real level, what benefit do I get from having the interface at all in this case. It doesn't really feel like its particularly helping loose coupling, although i know thats the reason for it.

Any pointers on this would be greatly appreciated!

Thanks


adi ian

Posts: 5
Nickname: adiian
Registered: Jul, 2006

Re: Programming to an interface Posted: Sep 19, 2008 12:58 PM
Reply to this message Reply
From various reasons:

- In the future you might want to add another type of news. The framework will be the same, working with the interface, with minimal changes.
- You can use the interface in another application. For example you can send it to me, I'll write an application that interface, while you'll writing implementations of news, in the same time. When ready my application can work with your implementation, like a plugin.

Rajiv Narula

Posts: 167
Nickname: rajivn
Registered: Feb, 2007

Re: Programming to an interface Posted: Nov 10, 2008 8:17 PM
Reply to this message Reply
Funny.
I wrote a post on this topic today on my blog

http://www.rajivnarula.com/blog/2008/11/11/program-to-interfaces-not-implementations/

I will be happy to answer any question that you may have on this

Flat View: This topic has 2 replies on 1 page
Topic: Your views on a sound design Previous Topic   Next Topic Topic: There is need an Object across JVM's Which Design Pattern is useful?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use