Tales from the jar side: Mockito 5 released, PragProgWriMo, Stable Diffusion and the Uncanny Valley, Twitter is evil, part 1000+, and Other clever posts
Shakespeare: "To be, or not to be?" Schrödinger: "See? This guy gets it."
Don’t feel like reading this newsletter? That’s fine — I’ll read it to you on the companion YouTube channel. Today’s newsletter is tomorrow’s video.
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of January 8 - 15, 2023. I taught my regular Getting Started with Spring and Spring Boot course on the O’Reilly Learning Platform this week, and completed another couple of Medium posts on Mockito for the pipeline.
Regular readers of (and listeners to, and now even 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 5 is Finally Here
I’ve been working on my upcoming book on the Mockito testing framework for over a year now. Some of the delays are my own bad estimation capabilities, typical of software developers (and others) everywhere.
PragProgWriMo and Other Unreasonable Goals
For example, in October of 2021, Pragmatic Programmers editor Margaret Eldridge published a post on Medium mentioning two interesting facts:
The Pragmatic Answers series at the company is designed for books that are short and sweet. They’re only about 50 pages in length and ebook only, so the idea is that they are quick to produce, quick to consume, and can focus on smaller topics that may not warrant a full book treatment.
November was National Novel Writing Month (NaNoWriMo). That’s a project where the goal is to create a 50,000-word work of fiction in a month. It’s designed as a way to get a new project started, though some people actually do finish an entire novel in that time.
Margaret suggested that writers might consider putting together a Pragmatic Answers book as their project. She called it PragProgWriMo.
I liked the idea. I’d just finished back-to-back-to-back books (Modern Java Recipes, Kotlin Cookbook, and Help Your Boss Help You), but the appeal of spending only a month cranking out a short book was undeniable, especially because I already had a book in mind. For the last few years I’d been teaching courses on the Mockito testing framework, and that class was made more difficult by the fact a lot of students didn’t really understand what mocks, stubs, and spies were all about. The Mockito documentation focuses on showing you how to use Mockito rather than those fundamental issues, so I thought a simple primer on how and why to use Mockito in the first place would be welcome.
Also, I had a bit of a gap in my schedule coming up. I might not be able to finish in November, but December was looking a bit thin, so I reasoned if I started in November, I certainly ought to be done with a 50-page book by January, right?
(I can almost hear you saying, “oh, you sweet summer child.” Honestly, I have no defense.)
Besides, rumor had it my hero / nemesis Venkat Subramaniam was planning a new book in the Pragmatic Answers series, because of course he was.
I therefore proposed the book, and Margaret agreed to edit it. Then, naturally enough, a consulting project came in that was going to require a half-time or more commitment for the next few months in addition to my regular teaching schedule. Then I learned, yet again, that just because I’ve taught something a few dozen times doesn’t mean I can translate that knowledge to text without it growing and changing in fundamental ways, just like my last book had. I initially proposed the book to be called Understanding Mockito, but we later changed that to Mockito Made Clear, which is an odd title but mostly works.
Long story short (too late, I know), most of the book got written in the Spring and Summer of last year. We then went through a Beta review process, which required some pretty extensive changes again. I finally finished up the book last November (ironically, during NatNoWriMo again). The delays from November to the present are mostly due to a scheduling crunch at the publisher — they already had a series of books they were planning to release over the holidays, and my book went to the end of the line.
(You will not be surprised to hear that good old Venkat somehow managed to publish two (!) books during that time. His Pragmatic Answers book is Programming DSLs in Kotlin, which came out in March, and the second edition of his Functional Programming in Java. He’s got another book, Cruising Along With Java, scheduled for next month as well. This is all a reminder never to compare yourself with Venkat Subramaniam on any scale whatsoever, other than maybe height.)
Mockito Version Changes, or My Personal Sword of Damocles
During the review process, I managed to contact a couple members of the Mockito core team. I wanted their feedback, but I also was wondering about their plans for future releases. I didn’t want my book to come out, only to have them release a major update immediately afterwards and make my new book appear out of date. The new release acted as my own personal Sword of Damocles hanging over my book.
Mockito is one of those open source projects that doesn’t have an official corporate sponsor, so changes happen when the core team members have free time. That meant there was no official schedule for those updates. They have a discussion board for questions (a Google Group, believe it or not, which gives you an idea how old it is), but it has very low activity, on the order of one or two posts a month.
I managed to get one of the core team members to give my book feedback, and during the process I asked him about the schedule. He confirmed that the release of version 5 was “imminent,” but that could mean anything. It wasn’t going to be a big change, either.
That’s pretty consistent with previous major version number changes:
Mockito 1 to Mockito 2 was a big deal, with major changes to the API.
Mockito 2 to Mockito 3 simply mandated that the minimum supported Java version was Java 8.
Mockito 3 to Mockito 4 removed a lot of the deprecated classes and methods.
In other words, if your code already used Java 8 and avoided deprecation warnings, it ran fine in Mockito 2, 3, and 4. If the move to Mockito 5 was going to be similar, than I all had to do was make sure my code ran correctly in the new version.
As it turns out, my book is officially scheduled to be released on January 25th. Yesterday (Saturday morning, January 14), Mockito finally released version 5.
Here is a summary of the major changes:
The minimum Java level is now 11.
The “inline mockmaker” is now part of the core, so you don’t have to add it as a separate dependency. You only need that when you mock static methods or final methods or classes, which I do in the book, but now I can use the core dependency alone.
A new method called
type()
was added to theArgumentMatchers
class, which helps you mock methods that take a variable number of arguments.
I immediately upgraded the GitHub repository associated with the book to Mockito 5, and, nothing changed at all. All the tests worked exactly as they had under the last 4.* version. Yay! There are a few words in the Introduction anticipating that everything would still work in the new version, and now, thank goodness, it actually does.
We can now officially cut down that Sword, Mr. Damocles.
Wandering through the Uncanny Valley
In the last few newsletters I’ve referenced a couple of the new AI-based tools for developers and others:
ChatGPT, also known as Mansplaining As A Service, which gives official-sounding answers to questions that sound good even when they’re wrong, and
GitHub Copilot, your AI pair programmer, which embeds in your development environment and suggests code as you type.
I mentioned last week that those were the primary AI tools in the marketplace, and I knew something felt off about that statement as soon as I said it. I later realized I was forgetting the text-to-image generation tools, like DALL-E 2, Midjourney, and the one I decided to play with, Stable Diffusion.
The reason I decided to use Stable Diffusion is that it’s free and open source. That means it isn’t quite as user friendly as the others, but at least I don’t have to worry about getting charged for experimenting. Also, I wound up watching a video on Nebula by analog_dreams describing a new user interface for Stable Diffusion called InvokeAI.
I decided to play along. My M1 Max Mac machine is pretty powerful and still has lots of room, so I figured I could handle the software. It took a bit of doing, but I was able to get everything working without too much trouble.
I have to say my results have been pretty disappointing so far. That could easily be me, because there really is an art to coming up with good text prompts for it, but I haven’t been wild about the results yet. Plus, if you wind up with any actual people in your images, you often wind up wandering through the Uncanny Valley, which looks just close enough to reality to be creepy.
The prompts I used are shown in the captions.
Not bad, I guess, but don’t look too closely at the dogs or they start to look very weird.
No. Just no. Maybe even “no, a world of.” Also, yikes.
Looks like most of that prompt got ignored, or maybe that’s an optimistic interpretation.
Again, that’s not really what I asked for, but as you can see it’s better to avoid faces if possible. I could live with this one, though it’s not really all that close to the prompt.
It’s a shame, really, because there are entire websites showing off galleries of more successful experiments. I borrowed this prompt from one of them, and the image it generated isn’t bad:
You can see that there’s a technique to composing those prompts. Since the program is running on my own machine, I’ll probably continue to play around with it. I also know these systems are improving by leaps and bounds. My hope is that the free, open source tool will improve along with them, because I don’t have any reason to pay for these, even ignoring all the ethical issues involved.
As an aside, I have to admit I can only play with this for brief periods at a time, mostly because of that uncanny valley effect. Anything with people in it runs the risk of looking seriously disturbing, and most of the generated pictures look a bit off no matter what you do.
Other Posts
Before I include any tweets, I have to mention the other big event that happened there over the weekend. Without warning or even acknowledgement, Twitter suddenly disabled access by all the major third-party apps. That included my favorite, Fenix for Android, which I used because there were no ads, no promoted tweets, no polls, and always listed the tweets in chronological order. Now it doesn’t work anymore, and Twitter won’t even admit they did it on purpose.
Elon really, really sux.
Karma Chameleon, Really?
The video is interesting, but the comments are even better:
“This is a commercial for al-Qaeda”
“I would immediately chew down the cyanide capsule I keep in my mouth”
“Why won’t God blow up the sun? Do my prayers mean nothing to Him?”
“Could they, you know, not?”
“And this is why we can’t have nice things”
I didn’t think it was that bad, but I laughed anyway.
Meat Is Back On The Menu
There are restaurants in Mordor, but you need a reservation first. One does not simply walk in. <rimshot>
Sick Burn
Apparently there was some right-wing nutjob silliness about gas stoves this week? And somehow I was fortunate enough to miss it? Good to know. Still, this was clever:
Okay, that’s funny.
Spelling is Overrated
Getting their just deserts.
(Somebody is definitely going to add a comment to tell me I spelled that incorrectly. And they’ll be right.)
Have a good week, everybody.
The video version of this newsletter should be uploaded on the companion 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:
Getting Started with Spring and Spring Boot, on the O’Reilly Learning Platform
Wrote two more Medium posts for the pipeline when Mockito Made Clear is released
This week:
Deep Dive: Spring and Spring Boot, an NFJS Virtual Workshop
Begin vacation in Florida. That’s right — next week I’ll become a Florida Man, at least for a few days