Spring Makes Java Better!

     Spring is a very popular Java framework that makes working with Java applications easy. It provides dependency injection using the beans, and it also contains other modules for MVC, Web Development, messaging and more. Spring is a lot of things, and although when I first saw it on countless job postings I assumed it was just for building REST API's, but it is for so much more than that. I just finished watching an excellent PluralSight video by Bryan Hansen that covers the basics of Spring, and we didn't even begin to cover how to build a REST API. Still, I completely understand why Spring is so useful in building large applications. 

     Spring cuts out the clutter and makes your code more business-focused. You can make Beans, which are kind of like components, and you can tell them what to be and what to do. For example, Beans default to singleton (unless you'd rather they be a prototype) so when you want to create an instance of an object, you only create one, without having to write a bunch of code to make it a singleton! Spring is a handy way of removing boiler-plate code, and it makes your code more easily testable. 

    You can see from these images that we have wired this Service component to be initialized so that when we create the service we can access the findAll() function initialize our speaker object. This way we don't need several lines of code to to tell our SpeakerService to be an instance of Speaker.

    I'm only getting started with Spring, but it reminds me a lot of ASP.NET, and I can absolutely see how it would be a fantastic way to organize your project. You can check out the code here! There is a method of using Spring in Java, XML and one without to compare.


Popular posts from this blog

API's in C#

Using WebRTC to build a videophone in React and TypeScript

Reviewing WPF and MVVM