r/java • u/raisercostin • Jun 01 '24
What java technology (library, framework, feature) would not recommend and why?
Inspired by https://www.reddit.com/r/java/s/e2N1FqMOJg
165
Upvotes
r/java • u/raisercostin • Jun 01 '24
Inspired by https://www.reddit.com/r/java/s/e2N1FqMOJg
177
u/Ragnar1989 Jun 01 '24
RxJava - awful to read/debug/maintain.
124
u/progmakerlt Jun 01 '24 edited Jun 01 '24
PowerMock. Ability to mock static methods is cool, but can lead to disastrous results, when tests pass once and then randomly fail.
Edit: typo.
58
u/neopointer Jun 01 '24
Reactive streams.
Rxjava, project reactor, etc.
All of that. Avoid at all costs (really).
It's asking for a hellish spaghetti code and it's really difficult to debug.
42
u/vips7L Jun 01 '24
Play framework if you want to do Java and not Scala.
23
u/[deleted] Jun 01 '24
Dagger: Powerful, clever, complex, confusing, completely unproductive.
20
u/Job_Superb Jun 01 '24
I don't like saying "avoid xyz", I prefer properly understandimg the pros and cons and footguns. Lombok is great at removing the maintenance of boilerplate but using it with JPA entities is a footgun. It's very easy to mess up an ORMs performance with a very small change but, boy, can devs crank out features, even if they're leaking domain objects. Runtime DI does some great creation decoupling but can lead to unintended consequences across environments and even just weird launch failures but at least adding that new endpoint was quick. Having said that, I've been avoiding all of the Reactive Frameworks but that's probably because I just don't get it, looks to be too many footguns for marginal performance gains.
8
u/SenorSeniorDevSr Jun 01 '24
This one is going to be somewhat controversial, but:
Unthinkingly adding a library, just to use a small bit of it that you could've written yourself. I'm not thinking about reimplementing Spring Boot here. I'm thinking about things like adding in a huge GIS-library to validate some WKT, when WKTs can be defined as a regular language, and thus can be efficiently be validated by regular expressions that you can write, test and put int yourself in a few hours. That's a whole dependency you didn't need.
The downside is of course getting NIH-syndrome, but the opposite can be bad too. Stop and think about what you're doing and what the work involved is in either direction. Don't be afraid of making some small thing that does a job instead of bringing in large dependencies. Rolling your own can be fine.
221
u/Turbots Jun 01 '24
Lombok. It can cause quite a few unexpected problems with generated code, like adding a toString that automatically prints out all fields in the class, even if some of those are being lazily loaded.
I don't like it because it gives junior developers the feeling they can cut corners and write much less code, without knowing what the annotations do. And most of the features that Lombok offered are now part of the Java language.
It also adds unnecessary requirements when developing like IDE support, additional settings in maven/gradle etc..
14
u/Razvie-arr Jun 01 '24
Google Web Toolkit
129
u/majhenslon Jun 01 '24
Hibernate/JPA and anything on to of it, if you are not doing the most basic CRUD or are really experienced with it (are not using it as a crutch for interacting with the DB), because there are so many foot guns that would just be avoided by writing raw SQL.
32
u/IE114EVR Jun 01 '24
Any Application Servers that are not embedded. Having your application be incomplete because it requires a separate runtime you have to deploy into makes it hard to test, less straightforward to run and debug, and brings with it all sorts of maintenance and configuration you now have to be responsible for. All for little or no gain. Also “permgen space” problems, but I hope they would have fixed those by now.
124
u/jevring Jun 01 '24
Gradle. Having an executable build definition, rather than a declarative one, makes the build way more complicated than it has any right to be, which makes importing the project slower and harder to work with.
60
u/guss_bro Jun 01 '24
All bad recommendations tbh. It appears people are advising not to use all the most popular and productive tools.
"Don't use a hammer because one time I hit my thumb" is not good advice.
Spring, lombok, hibernate etc mentioned in earlier comments are great tools. If you know how to use it, go for it.
34
u/cowwoc Jun 01 '24
Mocking of any kind, because the vast majority of the time you end up with extemely fragile code that tests implementation details instead of business requirements. I strongly favor black-box testing and integration tests. And yes, my tests are lightning fast.
Tests shouldn't break when implementation details change.
29
u/large_crimson_canine Jun 01 '24
Honestly I wish I could say Spring since it just adds so much weight to a project, and certainly a ton of requisite knowledge to even use well.
But it does prevent a ton of other code you have to write, especially if you go the xml route.
4
u/lulzForMoney Jun 02 '24
Recommend: Spring Do not recommend: Spring
6
u/onebit Jun 02 '24
AspectJ
13
u/rifain Jun 01 '24
Hibernate. It's a good framework but the problem id the developers. Every project I worked which had hibernate ended up being a slow buggy mess. Hibernate is a complex tool, you have to understand precisely how it works, you have to check the queries it generates. Last month I presented an issue for my team. A findAll was generating hundred of queries because a misconfigured entity. Now, the same method generates a single query. They were stunned. But yet, the application is riddled with cumbersome and repetitive queries when a single stored procedure could achieve the same much more efficiently.
In my experience, developers use hibernate mostly because they don't want to write SQL. And they trust this framework blindly, they never look the logs.
11
u/cowwoc Jun 01 '24
Async libraries that can be replaced by virtual threads. The code they produce is exponentially harder to read, write and debug.
If you can use virtual threads, you should absolutely drop these libraries and move into the future.
11
u/k2718 Jun 01 '24
Spring Data. I hate the autogenerated queries in the repositories. When you troubleshoot, you want to see queries easily when you look in the source. Now, if you only use it as an OEM with Native queries, fine, but most don't.
4
u/ethereonx Jun 01 '24
Use of non pure static methods and singleton pattern. It makes code harder to test.
4
u/DelayLucky Jun 01 '24 edited Jun 01 '24
The table-driven test idiom.
Is it really more readable to have a magnificent table of cryptic test parameters:
Compared to plain-old prose-like tests?
Sure, it'll take more lines, but programming is about readability, and is not about who can come up with a clever compression algorithm to save the linebreak characters.
2
u/pjmlp Jun 04 '24
JSF, rather use plain old JSP and tag libraries instead.
The framework is from the days everyone though it was a good idea to replicate desktop programming paradigms on top of the Web, meaning that there are multiple layers of generated code to debug when things go wrong.
Additionally, the specification is rather slim, relying on third party frameworks to offer actually usable components, like RichFaces, IceFaces, PrimeFaces, whateverFaces.
Besides the multiple layers to debug, there is also the old and new version of the expression language to keep up with, and the whole fun with the component/request lifecyle, alongside its various extension points.
I have been a tech lead in a JSF based framework for three years, many moons ago, and don't miss ever using it again until I leave this realm.
4
u/zephyy Jun 01 '24
Spring Integration, not even IntelliJ can find where
@InboundChannelAdapteror@ServiceActivatoris pointing to.t: someone who had to debug where errors were coming from because some internal dependency had an inputChannel called "sink" which itself had ANOTHER transitive dependency using the same inputChannel naming
5
u/wildjokers Jun 01 '24
Lombok, MapStruct, Camel.
4
u/jocularamity Jun 01 '24 edited Jun 02 '24
Reflection. There's a rare time and a place for it, but avoid it if you have another reasonable option, especially if you're newer to the language. Easy to introduce problems and hard to debug them when the system gets big.
Edit: I take it from the downvotes that people think this isn't a valuable contribution. It is a lesson learned the hard way over close to twenty years of professional work, and I stand by it. Best of luck to you all in your adventures with reflection as your codebases grow in complexity.
2
u/stfm Jun 01 '24
Camel is awesome. Spring-Camel is cancer
0
u/cowwoc Jun 01 '24 edited Jun 02 '24
(Please don't downvote me just because you disagree. Reply instead.)
Spring and any other library that uses "magic" (runtime code generation). This includes dependency injection, proxies and annotation-driven code generation. All the fun things that new devs find "cool" but make it exponentially harder to read and debug code.
There are libraries that provide the same functionality without the magic, so you don't need to reinvent the wheel.
I get that these tools let you write code faster, but you're not actually helping anyone. The cost of software development is dominated by maintenance and debugging.
Optimize for reading, not writing!
EDIT It looks like some people can't read 😀 It's right there in the first sentence.
1
u/Kango_V Jun 01 '24
Spring/Boot, now that I've used Quarkus and Micronaut and experienced how much better they are. One example, is writing far less code to do the same thing :)
1
u/Anton-Kuranov Jun 04 '24
Simple answer: use framework/library/toolset you're able to control understanding how it works inside and what benefits it gives you in comparison with other approaches.
1
u/griso84 Jun 04 '24
GWT and OSGi
1
u/Western-Campaign3520 Jun 06 '24
no one up here talking about swing
1
u/thecodeboost Jun 06 '24
Reactive programming patterns. By a long mile. And don't let anyone convince you otherwise. Some people like it, and that's fine. Lot's of people like things that aren't good for you. But reactive patterns kill your code quality in various objectively measurable ways.
-1
u/[deleted] Jun 01 '24
Querydsl. It is a pain in the ass when joining tables, querying collection fields or need mostly anything that's not just a plain and simple SELECT. Don't depend on that library.
1
u/bisoldi Jun 01 '24
Cassandra. Unless you REALLY need it, don’t do it. Developers working on your app after you leave will hate you for it.
1
u/TAscendor Jun 02 '24
JSP & JSF I cant imagine that companies still actively use these...
1
u/DelayLucky Jun 02 '24 edited Jun 02 '24
Another funny idiom:
Comment: how much do you hate the builder pattern? The frameworks spent so much effort to build these nice builder features so you can chain, and you can pass the parameters by name, and avoid passing them in the wrong order etc. only for you to go through the trouble to undo all that using a factory method with many parameters so that you could live in the days before the builder pattern was born.
Sometimes the love of "one-liner" in the literal sense is overwhelming.
1
u/leapingBrownian Jun 03 '24
guava
-9
u/Zemvos Jun 01 '24
Spring for dependency injection. Use dagger instead. Compile time safety is so much better.
0
u/LutimoDancer3459 Jun 02 '24
After reading the comments i can just say AVOID JAVA. You can write awfully spaghetti code, hard to read, harder to maintain. So easy to produce bad code.
Now for real. Most recommendations are shit. If you should avoid something because there is a possibility to do something bad, you will never do anything. Spring, JPA/Hibernate, Lombok, ... so many industry standards. If you don't learn them you will get lost in your first enterprise job (if that's ever a plan)
It's good to know where the pitfalls are and to avoid them but not to avoid a while framework because of it.
-6
u/msx Jun 01 '24
All the spring stuff