Tales from the jar side: Delayed validation in Mockito, DevNexus, World chess championship (sort of), Elon throws another tantrum, and Tweets and Toots
Best sign seen this week: "The 'lock her up' crowd is freaking out about 'lock him up'. See? Pronouns DO matter."
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of April 2 - 9, 2023. This week I taught the first week of my Android Developer Bootcamp on the O’Reilly Learning Platform. I also attended the DevNexus conference in Atlanta, GA.
Regular readers of (and listeners to, and now video viewers of) this newsletter are affectionately known as jarheads, and are far more intelligent, sophisticated, and attractive than the average newsletter reader (or listener, or viewer). 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.
Delayed Validation In Mockito
For the technical content this week (feel free to skip if you’re not interested), I want to talk about a new video I published on the Tales from the jar side YouTube channel. It’s called Don’t Verify That Mock (Yet)!:
It’s based on a tweet that I saw by Maciej Walkowiak:
He provided some code that suggested that if you want to verify a method in a dependency has been called, but it may take time to do so, you can use a second argument to the verify
method called timeout()
, which takes a delay in milliseconds. This really only works if you know approximately how long the delay is going to be.
In my demo, I added a method to a service that saves an entity into a repository, but does it after a short delay. The method in the service returns void
, and methods that don’t return anything are notoriously hard to test. One way to do so is to verify that when you call the method with a delay, it in turns calls a method on the dependency. You just have to wait long enough for the second call to occur.
The details are in the video, and in an upcoming Medium article I put together for the Pragmatic Programmers publication, and I added the code to the GitHub repository for my Mockito Made Clear book.
For those who might be interested, here’s the service:
And here is the associated test, with the call to verify
with a timeout
:
I explain all the details in the video and in the Medium post. The video has gotten over 100 views so far, which is a lot for me. :)
DevNexus Conference
I’m really bad about taking pictures. I know I should take more, but I’m just not in the habit of doing so. At the DevNexus conference, however, we had a bit of a Null Pointers reunion (the rock band of Java developers that plays at conferences occasionally), and we got a photo to prove it:
From left to right, that’s Paul and Gail Anderson, Frank Greco, Freddy Guime, and me. We weren’t scheduled to play, so I’m the only one who brought my instrument. Of course, it helps that I’m a singer. (rimshot)
I attended a talk by Paul and Gail about deploying applications made with the JavaFX graphics library onto mobile devices, which was fascinating. I spent a little time trying to get a trivial JavaFX app running on my machine and using the GraalVM native image compiler to build it, as per the instructions on Gluon. It eventually worked, but wow was it annoying, with way too many hoops to jump through just to get that far. Still, I’ve neglected Desktop Java for most of my career, and if I really can write a visual app and deploy onto desktop platforms and Android and even iOS, it might be worth the investment in time and effort. At least I know I have a good resource to contact when I have questions.
My friend Dan Vega also gave a good talk (with the infamous Nate Schutta) on Spring tips and tricks, some of which were new to me. As a developer advocate for Spring, Dan hung out at the VMware booth for a while and I got to chat with him about a variety of topics. Here’s a photo of the two of us after his talk:
Frank Greco gave a talk about pattern matching and ChatGPT, which was interesting, but most of which I knew from his earlier presentations. I like that a lot of work is being done these days to create Java libraries that interact with the machine learning tools. We’ll see how that develops in the next six months to a year, as things change rapidly.
The tragic part is I actually knew a machine learning joke and I forgot to give to him before his talk. The joke isn’t mine, of course, and I might have mentioned it here before, but here it is again anyway, updated for ChatGPT:
ChatGPT walks into a bar. Bartender says, “What’ll you have?”
ChatGPT says, “What’s everyone else having?” (rimshot)
The algorithm always tries to give you the most likely answer, get it? Yeah, I know what you’re thinking — maybe Frank is better off that I forgot to tell him the gag until afterwards.
I went to a handful of other talks, including a good one on Functional Kotlin. I also taught my Android class Wednesday evening from my hotel room, which was a bit of an adventure (hotel wifi connections being what they are), but it all went well enough.
Next year I really want to get my act together and send in some talk proposals before the deadline.
(As usual, one of the most difficult things about traveling is I had to wait to see the latest Ted Lasso episode until I got home to watch it with my wife. It was awesome, as usual.)
Chess World Championship — Or Is It?
This week begins a chess match between Ian Nepomniachtchi (pronounced “Yan Nee-PON-nee-shi” believe it or not) from Russia and Ding Liren from China. It’s supposedly for the World Championship, played at standard time controls (two hours for the first 40 moves, one hour added for the next 20, then 30 minutes for the rest of game, with a 30 second increment added after move 60). The thing is, though, the current World Champion is Magnus Carlsen, and he’s still the world’s best player, and everybody knows it. He just doesn’t want to do this “every two year” championship match cycle any more, so after ten years as champion, he’s not defending his title. That means that either Nepo or Ding will have the title, but will be widely considered to be, at most, the second-best player in the world.
The New York Times had this article about it (which I’m sharing here as a gift link so you don’t need to register to read it): A World Chess Championship Without The World’s Best Player. The article includes this image, from 2019:
That’s Ding on the left and Nepo on the right, with GM Anish Giri walking past in the background.
The article points out a couple of interesting issues:
Nepo is from Russia, but he has criticized the invasion of Ukraine and will be playing under a stateless flag (the FIDE flag, actually, which is the international chess federation). His past comments suggest he would probably say more against the war, but he still lives in Russia and that would likely be dangerous. That won’t stop Russia from proclaiming they have the world chess championship if he wins, though.
Ding is from China, and the reigning women’s World Champion, Ju Wenjun, is also from China, so if he wins both champions will be from the same country.
It should be a good match. Both players are excellent and evenly matched, so I have no idea what will happen. Carlsen crushed Nepo two years ago. It would have been fun to see him play Ding, but Nepo won the recent Candidates Tournament (again) to select the challenger. Ding finished behind him.
Former World Champion Garry Kasparov (one of the best players ever) said in an interview:
I can hardly call it a World Championship match. For me, the World Championship match should include the strongest player on the planet, and this match doesn’t. … It’s a pity Magnus is not there and naturally the match between Nepo and Ding is a great show anyway, but it’s not a World Championship match.
As for Magnus, they asked him in an interview who he thought was going to win. Here’s his response:
I believe him. I think if Ding had won the candidates, Carlsen might have changed his mind. He’s already beaten Ian, though, and I don’t think he was interested in doing it again.
Speaking of Magnus, he played his final tournament as World Champion in the Chessable Masters, a rapid-play tournament. He lost his first match, putting him in the “losers” bracket, but won all his matches there to get back into the finals against Hikaru Nakamura. Then this happened:
Here’s an article about the mouse-slip that cost him a queen and therefore the win. He still cares about his chess, obviously. :)
Sunday update:
The hashtag for the championship match is apparently #NepoDing, which fits.
Game 1 was a tense affair, with Nepo holding an edge for a long time before Ding neutralized it. The result was a hard-fought draw.
Elon Throws a Tantrum, Again.
This week I got an email from Substack (the platform that hosts this newsletter) describing their upcoming Notes product. It’s like a social media platform, expecting people to share notes, images, and so on, and vaguely resembles Twitter.
Apparently Elon Musk did not take that well. All of a sudden, and without warning, you could no longer embed tweets inside Substack newsletters. Worse, if you tweeted a Substack link, at first it was blocked entirely, but then Elon “backed down” and decided to show this image any time you clicked on a Substack link:
Just a masterpiece of passive aggression. Of course, the real result was that everyone ignored the message and clicked on “continue” anyway.
Then, by Saturday afternoon, Substack links were no longer blocked or encumbered, meaning his little tantrum was over. Can you imagine having your primary business (like William F. Leitch’s newsletter in the link in the above image, which I happily pay for) be at the mercy of an oversensitive man-baby like that? I’m not even going to get into his silly attempts to justify the block, based on statements that were completely untrue.
Here’s the article at The Verge entitled Twitter now disables likes, replies, and retweets if a tweet has Substack links. See also Substack writers say Twitter’s newsletter ban is bad for business — and worse for Twitter on the same platform. This tweet kind of said it all, though:
You may be aware that Elon’s other idiocy at Twitter this week is when he labeled NPR (NPR!) “state-run media,” mostly because he doesn’t understand the difference between “state-run” (like Russian Television) and “public”. Let’s give the last word to Benoit Blanc from the movie Glass Onion:
Miles Bron [stand-in for Elon Musk] is an idiot!
(I’m not going to get into the other scandal this week when it was revealed that that Tesla employees reportedly shared videos captured by cameras on customer’s cars. Feel free to read the linked post if you’re interested. Besides, I’ve never done anything untoward in my Tesla, as far as you know, and hopefully as far as the employees at Tesla know. I still love my car, but I can’t wait for the other EV companies to catch up.)
Let’s move on.
Tweets and Toots
Say This Three Times Fast
Doesn’t quite parse, but still.
Pitch Clock
Major League Baseball has instituted a pitch clock, to great effect, and both the pitchers and the hitters are adjusting. There’s a rumor, however, that MLB may decide to sell sponsorships on it, which is very silly. This response was the best:
Yet another demonstration that nobody does snark better than baseball writers, and Joe Sheehan is the best.
(In case you didn’t immediately get the gag, Roman is a brand of erectile dysfunction pills. Or so I hear.)
Happy Arrestmas!
I’m holding off on commenting on the arraignment, but this was funny:
I should hang up my shirts, but…
It’s a nerdy joke, but if you know, you know.
That would do it
Talk about burying the lede, right? (rimshot)
Life Hack?
I would never be brave enough to do that, but it’s a very clever idea.
Sequels
And finally, the best idea for a sequel I’ve seen all year:
And by sequel, I mean another sequel to The Muppet Movie.
Have a great week everybody!
The video version of this newsletter will be on the Tales from the jar side YouTube channel tomorrow.
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:
Week 1 of Android Development Bootcamp, on the O’Reilly Learning Platform
Devnexus conference in Atlanta, GA
This week:
Week 2 of Android Development Bootcamp, on the O’Reilly Learning Platform