The Essence of Spring

Rossen Stoyanchev

This happened in Atlanta last week while I was in a Barnes & Noble bookstore. I circled around to the computer section and began scanning titles. With my head tilted I overheard a conversation about a job. I wasn't actively listening but I knew one side was pitching a job while the other was inquiring about it.

A couple of minutes later it was just me and the guy who was looking for talent. I was sure he would start speaking. Soon after he said 'so you're in J2EE?' and so the conversation began. He asked me about my work. He didn't know about Interface21 but upon hearing it's the company behind Spring his face lit. He said he hadn't tried Spring yet and then added he was currently using Struts.

The association of Spring and Struts has come up on a few occasions before. It's not uncommon for people to hear of Spring MVC but not know much about the rest of Spring. For others Spring is mainly a framework for dependency injection. Given the ground Spring covers all this got me thinking how to best define what it's about to those who aren't that familiar with it yet?

It's probably easier to talk about Spring at length than it is to define it concisely but here is a shot at it. I challenge you to do it in fewer words so long as you imagine speaking to the gentleman from the bookstore.

Spring is about dependency injection of plain objects. Instead of creating objects yourself you tell a framework like Spring about it and let it configure them for you. I say "plain" to emphasize these objects aren't aware of Spring. Sounds simple? Once you let that happen you open the door to powerful AOP-style services through a proxy mechanism that intercepts calls to your objects and adds behavior in a transparent way. Want transaction demarcation or access to remote services without "polluting" your business objects? It's easy to do with a few more lines of configuration (no coding!). Spring uses this formula over and over again to provide transparent access to security, transactions, remoting and many other traditionally difficult to implement enterprise services.

So have a closer look. This is only a start. There is more to be said but the above in my mind captures an essence, paints a picture that's closer to what Spring is all about. On another level Spring is about keeping things simple and minimal.

Similar Posts

Share this Post
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Slashdot
  • Technorati
  • TwitThis
 

39 responses


  1. Spring is to J2EE as Mac is to windows? interfaces "just work".


  2. Hi James,

    I heard this one too last week from a group of people I talked to; I like it!


  3. I also always highlight Spring's modular nature and the fact that you can pick and choose, e.g. adopting the JdbcTemplate stuff without doing Spring DI: i.e. you can get a feel for Spring without having to completely overhaul your application.


  4. I've been asked the "what's this Spring thing all about then?" question a few times now and it IS hard sometimes to succinctly summarise it. There is SO much to it, but conceptually it is pretty simple. Put succinctly, that passage does seem to be as good an example of "what" Spring is as I have read. I just have to remember it now and plagiarise it when I'm next asked the question :) .


  5. I usually answer this question saying that Spring is responsable to create and wire objects with its dependencies. It make it easier to work with several frameworks hibernate, ibatis, quartz and others.

    I have one metaphor that I use to explain IOC too.
    Imagine that you are on a restaurant. You want one beer. You can ask for one and you will have. You dont need to know how that beer came to you. On other situation you ask for one beer and you get your beer and some fries. Spring acts like the waiter on this case. It will deliver to you what you need. But sometime you will have some gifts included.


  6. Hi Joao,

    nice one! Lately I've been using the a car plant as an analogy for DI, in combination with my demos that also use a car plant. Car don't assemble themselves, just as the individuals parts a car is made up of also don't assemble themselves into a car. It's the car assembly line that does the trick. This analogy also works quite well for me.


  7. Does Spring work on linux? harharhar.


  8. It's hardly "no coding" when the configuration for IoC takes as much, if not more, text than the line of code would, and there's nothing simple or minimal about thousands of lines of XML that isn't checked at compile time.

    JSF, Seam and other frameworks have IoC to varying degrees, and Spring is no longer unique. DI is after all a trivial piece of code, at which point, it's like saying you prefer C# and ASP.Net and buying into the whole .net framework because it has great 'for' loops.


  9. Dependency injection is based on long-established wisdom such as hiding implementation choices and reducing coupling among classes. These are core design issues one has to face regardless.

    In my experience dependency injection alone does simplify code far beyond initial expectations. It\'s something one simply must try.

    However the real point is about combining DI with AOP-style services to get things like declarative transactions and security that happen to work in any environment – standalone java, servlet or full-blown JEE container.


  10. If I had to, I would sum it up as: "Spring provides and enables a programming model that increases developer productivity across the board in an enterprise environment". I chose the words carefully – get the Thesaurus out if you want to tweak it, but that's it in a nutshell.


  11. I actually wrote a blog titled exactly this over a year ago! Cool.

    Here was my take, which was mainly inspired by another: http://www.jroller.com/page/kdonald?entry=the_essence_of_spring


  12. Spring has a lot of facets, so depending on the audience you can choose to let one sparkle that appeals the most. For developers it is surely this one imho:

    "When you have the feeling that some of code shouldn't be there Spring has a feature that will allow you to factor it out of your codebase."

    The moment that I truly fell in love with Spring as a developer was this:

    me: if (someString == null || someString.lenght == 0) throw IAE("yada yada");
    spring: Assert.hasText(someString);

    Many other people had that moment with one of the templates.

    It all boils down to the realization that finally somebody sat down and actually did that stuff that everybody always said that somebody should do something about some time.


  13. The moment that I truly fell in love with Spring as a developer was this


  14. thank you very much
    god night
    .bay


  15. thank you
    vary good
    fantastic:)


  16. thank
    very
    good


  17. Thank you useful info.


  18. Such a informative topic thanx


  19. Thanks man :)
    very good
    iddaa


  20. Thank you have a nice day


  21. Thanks man :) very good iddaa


  22. Does Spring work on linux? harharhar.


  23. unplayable pacman (or his female counterpart) is a tease. i give this a fail because it was almost an epic win. but failed to be epic.


  24. thanks. it's very exciting shared.


  25. Cok cok güzel bir site amkk sakldjald :D


  26. i think you


  27. very very good


  28. thanks very good post


  29. thankx you good


  30. Thanks good post.


  31. And now I need a tissue. I didn’t think in this age of porn and filth that I would ever find a site like this. God bless each and every one of you! Thank you!


  32. thanks very good post süper ötesi


  33. en güzel aşk şiirleri sizlerle …. perfect site thanks admin


  34. thank yopu webmaster wery good ninght


  35. Nice page, thank you ;)


  36. thank yopu


  37. thank yopu webmaster wery good ninght


  38. thanks very good post


  39. thankx you good

Leave a Reply