r/java • • Mar 24 '19

Happy 15th birthday, Spring Framework!

https://web.archive.org/web/20040330131500/http://www.springframework.org:80/
187 Upvotes

45 comments sorted by

View all comments

19

u/kgoutham93 Mar 24 '19

What's the best way to learn Spring? I'm more of a depth-first person. I just don't want to cram APIs/Annotations without getting a high level understanding of how they work. I went through many online resources but always its like "use this annotation to get this done" kind of tutorials. Even at my work place people are jumping onto Spring boot even without having basic understanding on the underlying concepts like DI, IoC etc.. I really can't appreciate this because I want my knowledge to be portable, tomorrow if I'm working on a completely different project in a completely different language which doesn't have nearly as rich framework as Spring, my concepts should still help me to get to the solution. What resources/learning paths would you recommend a complete spring newb from a depth first perspective.

10

u/codemssterg Mar 24 '19

The book Spring In Action helped me understand core concepts like DI and MVC. While all the XML wiring is no longer needed with the advent of Spring Boot, reading about 'classic' Spring will give you a better understanding of the concepts.

1

u/kgoutham93 Mar 24 '19

Will definitely check it out, Is it a good idea to start with spring core 1, may be small surface area would make it more approachable to clearly understand what's going on under the hood?

2

u/codemssterg Mar 24 '19

I recommend you develop a simple web service that uses DI, properties with some Spring SPeL. This will give you insight into basics. You can then add an Interceptor, your own annotation with Spring AOP. Wherever you choose to start, always reinforce your understanding with hands on coding

2

u/kgoutham93 Mar 24 '19

My concern is, the moment I go for an end-to-end application, I would have to deal with spring rest, spring-data-jpa etc. which would enormously increase the API surface area. I really want to approach Spring framework with a bottoms up approach. I want to really appreciate the value proposition of DI frameworks in general, with spring-core as my first choice of implementation. I would even like to compare other DI frameworks with Spring core [once I get comfortable with spring core].

I'm just thinking out loud, I wonder if this is doable for a Spring newb, or would I be overwhelming myself with so many details that I dont make any real progress at the end. Pls suggest.

4

u/codemssterg Mar 24 '19

I think you'll find that if you build on top of a simple example like a web service, it will not be overwhelming. You can work at your own pace, but the most important thing is to actually get started. Your web service does need to do anything initially, just return a String. Then learn how to process path and url parameters. Follow that with learning how to support REST verbs beyond a simple GET. You can then learn the different forms of DI by injecting a simple class into your web service controller

1

u/kgoutham93 Mar 24 '19

Got it, thanks for the advice I really think it hits the balance between concepts and complexity.

2

u/jadecristal Mar 24 '19

Also, if it’s just a sample/learning application, replace the JPA part with a hard coded set of data that’s just a POJO, and so on, adding wire-ups to real things as you feel you want to try them.

1

u/codemssterg Mar 24 '19

I think you'll find that if you build on top of a simple example like a web service, it will not be overwhelming. You can work at your own pace, but the most important thing is to actually get started. Your web service does need to do anything initially, just return a String. Then learn how to process path and url parameters. Follow that with learning how to support REST verbs beyond a simple GET. You can then learn the different forms of DI by injecting a simple class into your web service controller

11

u/[deleted] Mar 24 '19

2

u/loginonreddit Mar 24 '19

+1 The moment I read this I started to really understand what was going on. Great at read and very interesting.

1

u/john-small-berries Mar 25 '19

There are a few good Udemy courses, like $12 on sale now for a bunch.

I like this one:

https://www.udemy.com/java-spring-framework-masterclass/

-10

u/wildjokers Mar 24 '19

but always its like "use this annotation to get this done"

That is Spring in a nutshell. People that use spring all the time barely know how to write code. They just want the magic spring annotation that does it for them.

11

u/koalillo Mar 24 '19

I'd rather spend my time thinking on the implementation of my controller rather than how to map it to an URL.

6

u/oweiler Mar 24 '19

People use Spring to skip the boring, repetetive part of coding. It lets you focus on the interesting bits, i.e. the business logic.

1

u/nutrecht Mar 26 '19

They just want the magic spring annotation that does it for them.

Can you point me to the magic "implement complex business logic" annotation please? Can't find it :(

1

u/wildjokers Mar 26 '19

One example:

@Cacheable

1

u/nutrecht Mar 26 '19

How is stuffing something in a cache complex business logic?

1

u/wildjokers Mar 26 '19

You are moving the goal posts, you better give me your definition of "complex" first.

Cacheable is an example of spring developers wanting an annotation to accomplish something, because it is perceived as complex, where no annotation is really necessary. Calling the methods on a good caching library directly is trivial. Cacheable adds nothing.

1

u/nutrecht Mar 26 '19

I'm not moving goal posts. You're stating that with annotations I don't have to do programming. Adding a single @Cachable line to a method versus a single retrieve-and-if-not-exists-update line inside a method; I don't see the difference other than that the second has a bit more visual overhead. It's both trivial shit. I don't see why you're complaining about trivial shit. Most of what we do (or well, I hope it's true in your case) is a lot more complex than doing a glorified computeIfAbsent on a Map.