Tales from the jar side: Spring features new to me, Elon Muskrat Love, and funny posts
My parents insisted I loved alphabet soup, but I think they were just putting words in my mouth. <rimshot>
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of November 13 - 20, 2022. This week I taught the first week of my new Android Development bootcamp and ran an Introduction to Spring and Spring Boot course, both on the O’Reilly Learning Platform.
Regular readers of (and listeners to) this newsletter are affectionately known as jarheads, and are far more intelligent, sophisticated, and attractive than the average newsletter reader (or listener). If you wish to become a jarhead, please subscribe using this button:
As a reminder, when this message is truncated in email, click on the title to open it in a browser tab formatted properly for both the web and mobile.
New Spring Features, Or At Least New To Me
(This section is the technical part of this week’s newsletter. Feel free to skip it if it doesn’t interest you.)
I’ve been teach training courses on the Spring Framework since around 2007, which is right around the release of Spring 2.5, and long before the creation of Spring Boot. Since that time, Spring has grown enormously and been revised countless times. I’m usually pretty good at keeping up with the changes, but now and then something new slips through and I miss it.
This week my friend Craig Walls (fellow NFJS speaker and author of the book Spring in Action (currently in its 6th edition), one of the definitive references in the field) published a couple of YouTube videos that talked about new features in Spring 6.0, released last week. The one that came out this week was called Spring 6 and Declarative Clients:
It’s a good video, and I do recommend watching it, though the parts I want to discuss aren’t relevant to the main topic of the video. The “declarative clients” he talks about use annotations to replace a regular controller, and I’m fine with just using WebClient
or RestTemplate
classes to access my web services programmatically…
… except for the fact that apparently I’ve been “doing it wrong” for years. Not wrong, exactly, but in a way that’s more complicated than necessary.
Let me explain. In my basic Spring training course, the students access a third-party RESTful web service. Previously I used the ICNDB service (the Internet Chuck Norris DataBase), but that went down about a month ago and doesn’t appear to be coming back. Instead, now we go to the number of people in space service at open-notify.org. In the exercise, I suggest we write our own client class like this:
The points I make in class are:
Spring manages singletons by default.
Builder classes make natural singletons, so we autowire a
WebClient.Builder
into our constructor.If a managed class only has a single constructor, you don’t need the
@Autowired
annotation, but it doesn’t hurt to put it there anyway, for documentation if nothing else.In order to autowire into a class, that class must be a managed bean, so add the
@Service
annotation to it, which is another type of@Component
and therefore will be detected on a component scan.
(Hopefully all that makes sense in the context of the course, where we define what each of those terms mean and how the steps work.)
I was watching Craig’s video, however, and to create a web client he simply wrote in passing
WebClient.builder().build()
and went on. I had to pause the video and go, “Wait, what?”
It turns out if you look at the JavaDocs for WebClient, you find it has a static
method called builder
that returns a WebClient.Builder
, so the above call works. No need to autowire a builder into the class at all. I then saw that the class also includes a static
method called create
which takes the base URL and returns the WebClient
instance directly, so I can even reduce my code to:
Now it’s a one-liner, with no autowiring needed at all. Worse, I think those static
methods have been there since that class was created, so I could have been doing it this way all along.
It messes up my presentation, of course, because now I don’t have to talk about autowiring or the fact that Spring prefers to manage singletons, but the simplicity is worth it. Now I just have to get over feeling like an idiot that I’ve been missing this option for years.
Part of the reason I took this approach is that there’s no similar builder method for the RestTemplate
class, which I used to use all the time. For that one, I do have to autowire in the builder, so if I want to use both, it looks like this:
In chess, there’s a saying:
If you find a good move, pause before making it and see if you can find a better one.
I did something I knew worked with the other builder, and it worked with the new one, so I didn’t pause to see if maybe there was a better way. Now I know.
There were a couple of other tidbits I picked up from Craig’s video, like adding:
spring.main.web-application-type=none
to application.properties
to prevent the startup of the embedded server unnecessarily, and adding a netty-resolver-dns-native-macos
to my build to prevent an exception being thrown on my Mac M1 MAX, machine, but that’s enough for now. Feel free to check out the GitHub repository for all the details.
Elon Muskrat Love
I’m not going to recount all the idiotic moves Elon Musk made this week, which are destroying Twitter as a platform and as a company, other than to say one side-effect has been to remove any remaining mystique around Elon’s supposed “genius.” Frankly, the man is an arrogant idiot who doesn’t understand what he’s doing, doesn’t have a clue how to manage actual people, and fires anyone who challenges him.
His most bizarre move this week was announcing that Twitter was going to become hardcore (who, outside the porn industry, uses that term unironically?), and that if employees weren’t prepared to work long hours under intense pressure, they should accept an offer of three-months severance by the end of the day Thursday. The situation was best summed up in this tweet:
Apparently, Musk and his closest advisors realized Thursday morning that they had a problem. Too many people were going to leave. Musk had an online meeting late in the day to try to encourage people to stay, but when 5pm arrived, many attendees simply hung up.
Word is that nearly 75% of the remaining employees (that’s after cutting the staff by half last week and laying off 80% of their contractors early this week) took the severance. I finished my training class Thursday night only to encounter hundreds of tweets from people saying goodbye to their friends and promising to meet up elsewhere.
Here’s the thing: if you are a scientist and want to launch vehicles into space and you don’t work for NASA, you don’t have a lot of choices. SpaceX is pretty much the only company doing that on a regular basis. Likewise, if want to make electric cars with sophisticated tech, again, there aren’t a lot of choices (yet). But if you are a highly successful software developer with extensive experience working on global-scale distributed systems in the heart of Silicon Valley, believe me, you’ve got options. Maybe the hiring market is cooling down, but if anybody’s getting an interview, it’s you.
You might also note that in Musk’s original statement, there are no incentives to stay other than vague promises about building the future. No bonuses or promises of equity or raises, no extra freedoms, not even an assurance that the intense pressure and long hours will be temporary. There isn’t even a real vision about what he wants to build. Who would stay under those circumstances?
People who can’t afford to leave, that’s who. If you’re financially constrained, or on an H-1B visa and need an employer to sponsor you or you’ll be sent home, or you simply can’t give up your job on a moment’s notice and be sure you can get another one in three months. While some or all of those people may be high quality engineers, they’re not the “best of the best” that Musk thinks they are. The best people with any flexibility are now gone.
Then he decided to make this announcement:
That’s crazy, but it gets worse.
Again, who talks like that? What does “most salient lines of code” even mean? By the way, any true software person knows that sometimes your most valuable contribution is to delete code.
But then, best of all, was this:
In other words, Musk thinks it’s trivially easy to book a last-minute flight to San Francisco for a short meeting with him to justify your entire development career. Does he have any idea what it costs to book same-day flights, even assuming ones are available? Did he offer to reimburse the employees for that? Of course not, because in Musk’s world, he just shows up at his private jet and tells the pilot where to go, so why can’t everybody else do that?
As in the first Iron Man movie:
Tony Stark: Why are you trying to hustle me out of here?
Virginia 'Pepper' Potts: Your flight was scheduled to leave an hour and a half ago.
Tony Stark: It's funny, I thought with it being my plane and all that it would just wait for me.
Surely we can all fly like that, right?
I’m reminded of the best scene from the best episode of Season 3 of the Harley Quinn show on HBO Max. Episode 8 is called Batman Begins Forever, and features Harley traveling inside the mind of a traumatized Bruce Wayne, constantly reliving the death of his parents. She’s a (former) therapist, and is trying to heal him enough so that they both can escape.
The best lines of the episode, and arguably the whole season, go like this:
Harley: I always thought Batman was a stick in the mud, but seeing everything you’ve done all together like that is impressive, and honestly, kind of inspiring. But, you know, if you truly wanted to help Gotham, why not start with affordable housing?
Bruce (astonished): People pay for housing?
Isn’t that Musk all over? Fly in to meet me and show me why your code is important and I’ll try to squeeze you in before midnight. Maybe. What, people pay for airline flights? Ew, you probably even fly commercial. Yuck.
(There, I just made Musk’s whole day. I compared him to both Bruce Wayne and Tony Stark in one newsletter. You know he thinks of himself that way.)
Of course, late on Saturday he also posted this, because he can’t stop himself from doing stupid things:
… and Elon’s journey to the Dark Side is complete. I’m sure all those advertisers he’s courting will love that.
Incidentally, I have absolutely no faith in that “poll,” or that he would have cared about the results if they hadn’t gone his way. As someone pointed out, the full “vox populi” quote is:
Nec audiendi qui solent dicere, vox populi, vox dei, quum tumultuositas vulgi semper insaniae proxima sit.
which translates to:
Do not listen to those who say the voice of the people is the voice of God, since the tumult of the crowd is always close to madness.
There are layers in there (as you can see on this short Wikipedia page), as this is an argument against democracy. So Elon posting it works on yet another level, which I’m sure he didn’t intend but suits him completely.
That Bizarre Moment When The Captain and Tennille Threw Shade at Henry Kissinger
That may be the strangest collection of random words I’ve ever put in a newsletter, but it’s a real thing. Back in the mid 1970s, The Captain and Tennille had a string of top hits, including Love Will Keep Us Together and Do That To Me One More Time. They even wound up with their own variety show, which was a thing pop groups sometimes did back then. The show only lasted one season, but that was because they didn’t want to do it anymore.
Their unlikeliest hit, and arguably one of the most unlikely hits of all time, was called Muskrat Love, which was originally a cover hit by, of all bands, America (the same band that did A Horse With No Name). You can hear their version at this YouTube link. Their label begged them not to release it, as it would destroy any “hip” credibility they thought they had, but release it they did. It made it to #67 on the Hot 100, and all the way to #11 on the Adult Contemporary charts.
Daryl Dragon (the Captain in The Captain and Tennille) heard the song, couldn’t believe they were talking about muskrats, and shared it with Tennille. They both thought it was hysterical and added it to their club act, and the audience loved it. That’s how it eventually wound up on their 1976 album Song of Joy. The single hit #4 on the pop chart and #1 on adult contemporary and became part of their performance at the White House (with Queen Elizabeth in attendance) during the 1976 bicentennial celebration.
Apparently, not everyone at the White House dinner was impressed. Check out Tennille’s statement at the beginning of this performance on their TV show:
Tennille claims that Henry Kissinger — diplomat, scholar, and serious war criminal — was sitting four feet away from her piano as she performed the song, just staring off into the distance the whole time. She therefore dedicated this performance to him.
Now, far be it from me to defend a man like Kissinger, but I have to admit that Henry has my sympathies here. If I was stuck in an audience and someone inflicted Muskrat Love right in front of me, I’d consider that a form of torture, and if there’s one thing Kissinger knew all about, it was torture.
(I have to warn you, by the way: if you listen to that recording, complete with weird synthesizer effects by The Captain, you risk it getting stuck in your head for days.)
To bring this back to my previous topic, how funny would it be if everywhere Elon Musk went inside the Twitter offices, all he could hear was Muskrat Love playing in every room? That would be one of the greatest passive aggressive wins of all time. You know it would take him a while to realize people were making fun of him, and then to be unable to stop it or even directly acknowledge what it was doing? Fantastic.
If either of the employees left at Twitter by now decides to do this, please let me know.
Tweets/Posts:
In Other Rocket Man News
Some good news this week, as the Artemis I mission to the Moon launched.
There are several live trackers on YouTube, but I couldn’t figure out which were official, so I leave that to you. Suffice it to say the Orion spacecraft will be ready to loop around the Moon in about 15 hours and then head home.
(After dropping off Elon Musk? Sadly, no, not this time.)
The link in this tweet discusses all the science modules included in the mission:
There’s a lot more going on with that mission than you might realize, and that article gives a good summary.
Great Tom Gauld Cartoon
Tom Gauld’s cartoon is relevant this week:
The logical next step
They have a point
Meanwhile, on the Planet of the Tweets
Adopt your best Charlton Heston voice, and then:
And finally…
As a bonus, did you notice I didn’t make one single comment about the midterm elections?
You’re very welcome. Have a great week, everybody. :)
In case you need the link, on Mastodon I’m at https://mastodon.social/@kenkousen.
As a reminder, you can see all my upcoming training courses on the O’Reilly Learning Platform here and all the upcoming NFJS Virtual Workshops here.
Last week:
Android Development Bootcamp (week 1), on the O’Reilly Learning Platform
Getting Started with Spring and Spring Boot, ditto, in the APAC time zones.
This week:
Android Development Bootcamp (week 2), on the O’Reilly Learning Platform
Happy Thanksgiving! (in the US, anyway)