This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Framework & interfaces

 
Kunal Sathe
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Svein Erik Løvland
Greenhorn
Posts: 8
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and it makes Unit-testing easier.
 
Kunal Sathe
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks folks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic