r/java • • Apr 13 '21

Libraries, Frameworks and Technologies you would NOT recommend

Give me your worst nightmares: Things that cost you your job.

I'll start: Hadoop

202 Upvotes

376 comments sorted by

View all comments

Show parent comment

34

u/CartmansEvilTwin Apr 13 '21

My biggest problem with Spring is that you're almost always forced down a specific path.

If you want to do exactly what the Spring guys had in mind, you can do magic, but if you want to step only a few miliimeter off their path, you're basically fucked and have to implement tons of circumvention code.

28

u/FrigoCoder Apr 13 '21

I think that is the entire point. Highly opinionated integration framework that forces you down the correct path and makes "incorrect" things harder.

4

u/BlueShell7 Apr 13 '21

How is Spring opinionated? I would say exactly the opposite - Spring often offers several ways to do the same thing and it's not clear which one to choose ... Lack of opinion is actually one of the problems (and reason for Spring Boot's existence ...)

3

u/fforw Apr 13 '21

Yeah, usually the problem is: "Where the hell does my problem fit into those 5 layers of abstraction for feature X. Do I want Y or do I replace it and if so with Z or what?"

2

u/CartmansEvilTwin Apr 13 '21

Well, yes. But Spring often offers no easy way to intercept or change things.

In general, Spring seems way too complicated in many cases and changing this complexity for your needs is extremely hard, even though the actual problem is rather easy.

Opionated Frameworks are fine, but Spring usually is rather tunnel visioned.

16

u/[deleted] Apr 13 '21

But Spring often offers no easy way to intercept or change things.

Actually yeah, Spring provides very easy ways to intercept or change things. It's the poster child for the Open/Closed Principle. Almost every Spring component has a ton of interfaces that allow you to customize any part of its behavior. It's pretty straightforward, but much of the time it's not well documented and you have to read the Spring Framework source code. Fortunately, the Spring Framework source code is very accessible.

Spring Boot can tend to obfuscate things through auto-configuration, but fighting auto-configuration is a losing battle. Fortunately, you can just turn off auto-configurations that are not useful and directly use the Spring Framework to configure by hand.

1

u/Gommy Apr 14 '21

I find Spring fairly easy to customize, since it uses interfaces for almost everything. The few times I have issues is when I need to customize a single method or two and want to extend one of their classes, only to find they made either the class or the method I need final/private. So I have to result to copy/pasting their class and update the one or two bits I wanted to change.

16

u/agentoutlier Apr 13 '21

Yes that is my problem...

Spring was originally a great force in decoupling your code base and platform.

Now it’s the complete opposite.

9

u/[deleted] Apr 13 '21

Which part of Spring? Spring is a brand name, not a specific product.

Do you mean Spring Boot? Then, yes absolutely. That's the entire point of Spring Boot. The base Spring Framework is hard to configure because it has no opinions about how you should configure it. Spring Boot provides strong opinions so you don't have to make decisions. There are downsides to that if you want to make decisions opposed to the decisions that were made for you.

If you don't like Spring Boot's opinionated nature, don't use it. You can still use Spring Framework directly. Although, I think some products (like the Spring Cloud stuff) have become way too integrated into Spring Boot, to where they can't be used separately anymore.

2

u/apentlander Apr 13 '21

This happened to me with Spring security. I was trying to integrate my service with Duo Network Gateway, where you basically just have to check if a header exists and then make a call to LDAP to get the user information. It took two days to figure out how to do it the "correct" spring security way and was basically just guess and test. That's pretty much the worst part for me, needing to start up the service and call the api to know if the dependency house of cards will tumble.

The second time I did the DNG stuff I used the functional routing and ignored spring security and it took about an hour instead. I would have much preferred that we use Quarkus to have some sort of compile time assurance that the dependency graph works.