aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes coding to an interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "coding to an interface" Watch "coding to an interface" New topic
Author

coding to an interface

flora kalisa
Greenhorn

Joined: Sep 08, 2012
Posts: 2
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

Joined: Jan 10, 2002
Posts: 61206
    
  66

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.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Anurag Verma
Ranch Hand

Joined: Mar 30, 2012
Posts: 124

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
 
subject: coding to an interface