Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compare Spring and ServiceLocator

 
Chandra Mohan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

How do you compare Spring and ServiceLocator Pattern? Which is better and Why?


 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you like Blondes, Brunettes, or RedHeads, and why? ;)

Well the question is very open ended and I doubt you will get a full answer. But ServiceLocator is a pattern, Spring is a framework. You can do a Google search to find out the difference between that. Also Spring framework uses lots of design patterns, not just one.

Mark
 
Chandra Mohan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, This is one of the question has been asked in recent interview. I have very clear idea about the frame work and design patterns. It is open screat that spring has collection design patterns and service locator is one of the design pattern which has been included in spring. As per my understand (differences), Spring services are injected into your business classes rather than the business classes looking up a service.

I don't want full answer, Just to get the knowledge. I will not post this message if I get the answer in google, If you find anything in google search, give me link.

Any other differences ??
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose that you mean Spring IoC and Service Locator.

Spring IoC is better in terms of dependency management, the dependent doesn't look up or create dependencies, the control is inverted, the dependent just defines interfaces and the container injects dependencies to the dependent (dependency injection that is).
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I guess a good simple explanation on the difference is that Inversion Of Control is pretty much the opposite of ServiceLocator. Instead of looking up its dependencies. the dependencies are injected into the class instead. But there is so much more with Proxies and AOP to add services like Transactions and stuff. That is why it becomes a comparison of Apples to Oranges and would require a very lengthy post to list all the differences.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic