Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

coding to an interface

 
flora kalisa
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I had a discussion with my colleagues about coding to an interface.
I have 2 questions :

- coding to an interface is a good practice, is this statement correct ? why ?
- coding to an interface is good especially with spring, why ?

regards,
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
flora kalisa wrote:
- coding to an interface is a good practice, is this statement correct ? why ?

Because it decouples the calling code from implementation details that don't matter, making it more robust. The implementation details behind the interface can be modified without the calling code needing to be aware of it, or to have to change.

- coding to an interface is good especially with spring, why ?

See #1.
 
Anurag Verma
Ranch Hand
Posts: 166
Hibernate Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Bear, Interfaces are supposed to be contracts, & you should always share/code to contracts, never hard bind it with implementation.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic