Yeah, it really is a sad story. He was clearly vastly intelligent and despite his projects being a little bit deranged, it's still mad impressive what he managed to accomplish by himself.
Welcome to reddit. Where if you don't have a /s you will be ridiculed and down voted a majority of the time. Especially on any subreddit with politics or finances.
The code in the post is bad, but it has nothing to do with Spring. You could just throw an Exception (either a custom one or a generic one like ResponseStatusException).
If you want actually painful Spring design there is Spring JPA which allows you to put JDBC queries into interface method names and leave the function undefined like so:
Imagine not just naming the method correctly. What on earth kind of a name is ddcbbad??? Seriously. Just type out “departureDateCannotBeBeforeArrivalDate”. It looks like you’re using IntelliJ, you can autocomplete references to variables when typing them. So if you start to reference it by typing “departure” (or even less characters) you can autocomplete to it by using the arrow keys and the enter key.
Not to mention the string value can be made much more readable using underscores.
In fact intellij allows you to type an "acronym" based on the capitalised letters and it'll suggest the function correctly, so they can type in their weird acronym and still have a meaningful function name
So many things wrong with this but also need to call out that this validation error returns a 200 response when called. I am pissed just thinking about this mousetrap of an API.
227
u/missingdays Dec 24 '21
Are you sure it's the Spring's fault?
92
u/thatguydotjava Dec 24 '21
When you don’t believe in exceptions
24
u/erinaceus_ Dec 24 '21
Seems rather pebcac to me.
53
u/hypino Dec 24 '21
Lots of reasons this is bad, and not one of them is Spring.
27
u/SwedzCubed Dec 24 '21
Imagine not just naming the method correctly. What on earth kind of a name is ddcbbad??? Seriously. Just type out “departureDateCannotBeBeforeArrivalDate”. It looks like you’re using IntelliJ, you can autocomplete references to variables when typing them. So if you start to reference it by typing “departure” (or even less characters) you can autocomplete to it by using the arrow keys and the enter key.
Not to mention the string value can be made much more readable using underscores.
20
u/fletku_mato Dec 24 '21
Spring did not make you do this.
27
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Dec 24 '21
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
6
u/TheChilliPL Dec 24 '21
What's that earth icon?
3
u/cheezballs Dec 25 '21
Not even following camel case on those endpoints. Christ Id hate to work with your API!
3
u/[deleted] Dec 24 '21
This isn't Spring's fault...
2
u/emantos Dec 25 '21
Wow. 10+ years of Spring and I've never had to write code like this. Are you sure it's Spring's fault? Lolz.
1
u/Fury9999 Dec 25 '21
Attack!
1
u/rtmcmn2020 Dec 25 '21
So many things wrong with this but also need to call out that this validation error returns a 200 response when called. I am pissed just thinking about this mousetrap of an API.
0
u/[deleted] Dec 24 '21
Let's you*
-1
u/rightfor Dec 24 '21
If you re-write the same code in nodejs, flask or even django, you'll have a big surprise.