aspose file tools*
The moose likes Spring and the fly likes Spring Framework & interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Framework & interfaces" Watch "Spring Framework & interfaces" New topic
Author

Spring Framework & interfaces

Kunal Sathe
Ranch Hand

Joined: Apr 08, 2005
Posts: 49
Hello All,

I am new to Spring Framework and hence this question.

Is it always necessary to create Interfaces and implementation classes in order to take advantage of Inversion Of Control?

Thanks,
Kunal
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

I'm not Spring authority but no, I don't think so.
Creating interfaces and implementing classes is a best practice/
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

John Todd wrote:I'm not Spring authority but no, I don't think so.
Creating interfaces and implementing classes is a best practice/


If you want to configure transactions or AOP or other integrations that causes Spring to create a Proxy, then it will need an interface for the real object as it uses DynamicProxies to create those proxies. You can still not have an interface, but you have to add a configuration to those beans to use CGLib and generate proxies by subclassing the real class you want to make a proxy for.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
You can use IoC without using interfaces. Anyway, when doing object-oriented whether you're using IoC or not, you should have interfaces to make the design flexible and easy to understand.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Svein Erik Løvland
Greenhorn

Joined: Nov 13, 2009
Posts: 8

and it makes Unit-testing easier.
Kunal Sathe
Ranch Hand

Joined: Apr 08, 2005
Posts: 49
Thanks folks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring Framework & interfaces