Tales from the jar side: A Mockito video, YouTube Shorts, Silly certificates for silly accomplishments, Some people just hate mocks, AI tools for developers, and the usual Tweets and Toots
Me: "Did you hear that Old MacDonald's farm has been taken over by Artificial Intelligence?" My wife: "AI?" Me: "AI." Her: "Oh."
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of May 28 - June 4, 2023. This week I taught my Functional Java, New Features In Java, and the second week of my Spring and Spring Boot in 3 Weeks courses, all on the O’Reilly Learning Platform.
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.
Mockito’s inOrder Method
I was very active this week on YouTube. I published one video, on using the inOrder
method inside Mockito to check that methods in the dependencies are being called the right number of times, with the right arguments, in the right order.
I rather like the purple gradient background and the fonts, and they seem to go pretty well with the Mockito logo. YMMV, of course.
The story of this video involves ChatGPT, however. I have some examples of the inOrder method in the GitHub repository for my Mockito Made Clear book, but they all are part of larger examples. For the video, I needed something simpler that just showed the parts I wanted to illustrate, so I went to ChatGPT.
It immediately gave me an example that used a PaymentService
that depended on a PaymentProcessor
. The processor had two methods: authorizePayment(double)
and capturePayment()
, and the idea is that a payment needs to be authorized before it is captured. ChatGPT gave me a method in PaymentService
that did that, and a test that proved the the methods were called in the proper order. The results were simple, intuitive, and exactly what I needed.
I then asked it to generalize that to a class with two dependencies, so I could show the same process worked across multiple mocks. It added an OrderService
(to test), with dependencies PaymentService
(from above) and ShippingService
. The idea was to demonstrate that the processPayment(double)
method on the PaymentService
was called before the processShipping(String)
method was called on the ShippingService
.
Again, the resulting example and tests were easy to understand and demonstrate. The whole experience was frankly rather intimidating. I kind of wish I’d had this tool available while I was writing the book, to be honest.
I think it’s one of my best videos, partly as a result of that nice example. It did wind up generating some controversy, however, which I’ll get to later in this newsletter.
(That’s called foreshadowing.)
YouTube Shorts
I wound up publishing four (!) shorts this week. Here are links to them:
It’s probably clear from the titles, but three of them are about Mockito, and one about a feature of JUnit. Somehow — and this is an ongoing problem for me, which I’m working on — I managed to feel guilty that I did “only” four of these, given that my goal was to crank out one a day for about a month and see how that helps my subscriber numbers. (One of the videos I watched recommended doing that as a way to break through.) Each of my Shorts got between 60 and 100 views, which is pretty good, at least for me, and I’m currently up to (just checking…) 366 subscribers. Hey, progress.
I made a QR code
I found the QR code generator app inside Canva, and made this:
It represents the URL for the Tales from the jar side YouTube channel. I’m thinking of adding it to my slides from now on. It has a transparent background, but there’s still a lot of white space around it, so I’m not sure how distracting it will be.
I should probably make a QR code for the newsletter, too, and maybe even for some of my books, but that’s starting to sound like work.
Silly Certificates for Silly Accomplishments
I originally planned to put each of these images in the background of a future video, but it turned out there wasn’t room. I posted an earlier version as a carousel on LinkedIn, but then I couldn’t resist adding music and animations and turning into a YouTube short, called Silly Certificates for Silly Accomplishments:
The LinkedIn post has more of them, but I liked this version too.
Some People Just Hate Mocks
Okay, I’ve stalled long enough. I ran into an issue this week that I knew I’d encounter sooner or later. Given that, it’s remarkable that it took this long to happen.
To give you an idea what it is, check out this comment on my YouTube video
I case that’s too small to read, here’s the text:
Testing implementation details is an anti pattern that produces maintenance woes.
Test behavior.
Oh, and ditch your mocking framework to reduce cognitive load. F “mastering” a mocking framework. Master writing good DI object-oriented code and you’ll find it faster and dead simple to write fakes.
The comment was on my latest Mockito video, but it could have been added to any of them. I went back and forth with this guy a couple of times (I hate leaving comments unanswered), but then this happened on LinkedIn of all places:
See that? 19 comments, which is way more than I’ve ever received on any social media post, and they all basically hate on the very idea of using a mocking framework like Mockito.
That’s the real issue. None of the commenters cares about the details of what I said. They all just hate the idea of mock objects. They see it as a bad practice, or an anti-pattern, or whatever pejorative occurs to them at the time. At first I tried responding, but it didn’t help.
The problem, in a nutshell, is:
A small but vocal minority of the developer community hates mocking frameworks.
I knew they were out there, and I know there’s no arguing with them. They’re sure of themselves and dug in — it’s like a religious conviction with them. I must admit I actually knew that group was out there before I even started my Mockito book, and I wondered when I would attract this kind of negative attention. As I say, it’s rather remarkable it didn’t happen until now.
Suddenly, the idea of marketing a Mockito book, already a Sisyphean task, just got much harder. Or, maybe I should acknowledge that it was always going to be difficult, and should probably be happy it sold as well as it did.
So what do I do now? I’m not sure. I don’t want to see every Mockito-related post I make get attacked. That’s a possibility, but I figured it was a small one because my reputation isn’t big enough to be noticed. Still, I didn’t expect this video — out of about a dozen videos and shorts about Mockito, not to mention a whole series of article on Medium — to suddenly be the one they noticed. Will they hang around, waiting for me to publish another? I have no idea.
The funny part is, since I knew this was coming sooner or later, I already had my answers ready. In shortest possible form, they are:
I’m not advocating for mocks and stubs. I’m teaching people how to use Mockito correctly. They can do whatever they like with that knowledge.
My experiences with the framework is that the API is a bit odd and the development team is hard to reach, but it works fine once you understand the basic concepts.
Heck, two of my videos (How Mockito Mocks Help and Why Use Mockito At All?) contain detailed explanations of where I believe Mockito is useful. None of the critics, however, are apparently interested in watching those.
That’s too cynical. To be honest, I think they’re just reacting emotionally to a post that happened to cross their paths. I seriously doubt they expect me to suddenly go, “Hey, you’re right, I’m giving up on this entire idea I spent all those months writing a book about. Thank you for saving me from the evils of mocking frameworks.” Yet, that’s the attitude expressed in the comments.
I suspect I now understand why the core team members are “hard to reach,” as I said.. If I was on the core team, I doubt I’d want to hear the inevitable protests either, especially after you’ve explained your rationale multiple times.
I suppose the best consolation I have is the knowledge that, on YouTube at least, nobody reads the comments.
GitHub Copilot and Other AI Tools
After the initial trial period ended, I subscribed to GitHub Copilot (“Your AI Pair Programmer,” as the propaganda puts it), and added the plugin for my IntelliJ IDEA development environment. As I mentioned in an earlier newsletter, I leave it on during my courses in order to show the students what it’s like to work with an AI tool like that.
This week I talked to Jay Zimmerman, who runs the No Fluff, Just Stuff tour, about adding a new talk to my list, called Practical AI Tools for Java Developers. I’m going to give it for the first time at UberConf, in Denver, next month (July 18 - 21, 2023). I plan to talk about ChatGPT, GitHub Copilot, and other similar tools. I’ll probably also demonstrate Canva’s bulk create wizard, combined with ChatGPT, to generate an entire YouTube Short in about 10 minutes.
(Hey, I have to find some way to leverage all this time I’m spending building a YouTube channel for my actual job.)
As usual, I watched a few current videos on this stuff, and discovered to my surprise that IntelliJ is way behind the Visual Studio Code (known as VSCode) editor when it comes to Copilot integration. I suppose I shouldn’t be surprised, given that GitHub is now owned by Microsoft, which also produces VSCode, but I was anyway.
I don’t really want to switch to VSCode, but so many people use it I should probably get better at it. I’m at the stage where I can do the basics, but if anything goes wrong, I’m stuck. I’ll see if I can use it a bit more often and learn it better.
It also turns out there’s a follow-on project, called GitHub Copilot X. That project shows the “vision for the future” of AI-powered software development, and has all kinds of cool features in various stages of development. It’s also based on GPT-4, the latest and best version, and — here’s the kicker for me — it’s only available inside VSCode. I guess that’s yet another reason to work with VSCode, which, fortunately, is free.
Tweets and Toots
Lunch, Dinner, Supper,Afternoon Tea…
That’s all I’m going to say about that.
No, I need to include this one:
Okay, maybe one more:
And this (image linked to original tweet so you can watch the video):
And this, too:
That’s enough, at least for this week.
In PGA vs LIV, it’s all about the $$
In case you were not aware, the Saudis have been engaging in the most massive sports-washing operation in history by setting up their own golf league and paying top players absurd amounts of money to be in it. This has led to war (more or less) with the PGA, with golfers lining up and spouting incredibly hostile rhetoric.
This week, in a shocking move, the Saudis essentially bought the PGA:
The PGA Tour and LIV Agree to Alliance, Ending Golf’s Bitter Fight
(gift article at the New York Times)
A lot of golfers stuck with the PGA, turning down millions in the process, and are not happy. So are some other people, best exemplified by this awesome tweet:
Kind of says it all, doesn’t it? Money wins in the end.
I’ve never seen an outcry this big, however, so we’ll see if the “merger” (again, it’s more of a sale) goes through.
Apple’s New Headset
From everything I heard, Apple’s new Vision Pro headset, announced at their world-wide developer conference, is an incredible experience. This tweet, though, was great:
I’m thinking the reasons we fear to use it are (1) the lousy battery life, (2) the weight on your head, and, of course, (3) the fact it’s going to cost a whopping $3500 when it comes out next year. But from all accounts, it’s amazing and it’s only going to get better.
Besides, Mark Zuckerberg (who renamed his company from Facebook to Meta in anticipation of devices like this (quoth Apple: Sux to be you)) criticized it, so it’s got that going for it, which is nice.
Explains A Lot
Oh, like you’ve never missed a scheduled trip before?
Sorry, Kevin
Yeah, oops. Maybe don’t do that.
Don’t be that one
The caption reads, “There’s always one guy in every species.”
Do Two Wrongs Make A Right?
I linked this to the original Mastodon post, so you can decide for yourself.
The embedded video is a mashup of All Star by Smash Mouth and Never Gonna Give You Up by Rick Astley, sped up so it syncs perfectly. I can’t remember the last time so much effort was spent on such evil.
Here’s a link directly to the video, but beware, Dark Gods have been summoned by less.
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 2 of my Spring and Spring Boot in 3 Weeks course on the O’Reilly Learning Platform.
Functional Programming in Java, on the O’Reilly Learning Platform.
Making New Java Features Work For You, ditto, in the APAC time zones.
This week:
Functional Java, as an NFJS Virtual Workshop
Mockito and the Hamcrest Matchers, on the O’Reilly Learning Platform
Week 3 of my Spring and Spring Boot in 3 Weeks course, ditto.
Yikes. I forgot to change the dates again. This is the newsletter for the week of June 4 - 11, 2023. Sorry about that.
Watched the show more/show less whole video but did not see what I was looking for.
Indiana Jones video was great and about the right length and the ending was great.
The ark joke was 10 out of 10. Have the rimshot ready for this one.