Tales from the jar side: JUnit Assumptions, Barbenheimer, Elon hits bottom and starts digging, Tesla lies, and more Toots and Skeets and other posts
15 + 15 is thirty. 16 + 16 is thirty too. (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of July 23 - 30, 2023. This week I taught my Managing Your Manager course 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.
Never assume, unless you’re using JUnit 5
This section contains the technical content for this week. Feel free to skip it if you’re not interested. Of course, you could skip everything else, too. Hey, I’m not the boss of you.
When I started my career change from engineering to IT back in the late 1990s, I went back to school at night at Rensselaer at Hartford (at the time called the Hartford Graduate Center). One of my first courses was an introduction to object-oriented programming. That class featured a text called Object Oriented Software Construction by Bertrand Meyer, which introduced a programming language called Eiffel.
As the Wikipedia article says, “Many concepts initially introduced by Eiffel later found their way into Java, C#, and other languages.”
That about sums it up. I’ve never seen it used since, and I’ve only run into a handful of developers over the last twenty five (whoa) years who have even heard of it.
Still, it taught me one very important lesson, and that was called Design by Contract. The idea there was that every method in a class had both preconditions and postconditions. Postconditions are boolean expressions that are true when a method exists, but only work if the preconditions are true on entry.
As a trivial example, imagine I give you a task to do. The postcondition is that the task is done. The preconditions are things like, do I have the authority and the budget to ask you to do it? Do you have the tools needed to do the job? Do you have time to do it? Some of these I have control over, and some I don’t, but all of those have to be satisfied if there’s any chance you’d be able to complete the job.
In Java, there have been libraries for that sort of thing over the years, but none of them ever really caught on. Instead, Java uses exceptions to check precondition violations. But now, JUnit 5 (known as Jupiter), has a class called Assumptions
specifically to check preconditions.
The JUnit documentation has a good example of how the Assumptions
class it to be used.
The idea is that we want to test the pop
method in the Stack
class. When you call pop
, the postconditions are:
The top element of the stack is returned, and
There is one less element on the stack than there used to be.
Both of those can only be true, however, if the stack wasn’t empty when you called pop
. That’s the precondition — the stack must not be empty.
The assumeTrue
method in the code sample is a static method in the Assumptions
class. If it is not satisfied, the rest of the test is skipped, not failed. That’s the key. The idea is, why run a test that has no chance of succeeding? If the stack is empty, don’t call pop, because there’s no way it can do the job.
If you call pop
on an empty stack without the precondition check, it throws an EmptyStackException
, of all things. That makes sense from a naming point of view, but according to Design by Contract, that’s not how exceptions are supposed to work. In Design by Contract, exceptions occur when the preconditions are satisfied and the postconditions fail anyway, which means you’ve got a bug in your program. Since Java never had precondition checks, it uses exceptions for that purpose.
It’ll be interesting to see how much this capability catches on in the Java world, if it catches on at all. I’m planning a video on the topic, which is likely to be another in a series of videos that get very few watches, but I still think the topic is interesting and more people ought to know about it.
Barbenheimer
I saw the Oppenheimer movie this week, and it’s every bit as good as people say. The acting is fantastic, the cinematography and effects are amazing*, and the pace moved right along so quickly I never noticed the long run time.
*I referred to the movie’s “cinematography and effects” as though I have any idea what I’m talking about. Wow, maybe I am a real YouTuber now.
As I now do every time I see a “big” movie, I dug into the associated YouTube videos. That was interesting and disturbing, mostly because it forced me to spend a bit too much time mulling over the end of civilization by nuclear annihilation. I must admit I’m not really worried about that, however, mostly because I’m pretty sure climate change is going to get us all first. Sigh.
I remember when I was just a freshman at MIT, I read Richard Feynman’s autobiography, Surely you’re joking, Mr. Feynman! Like every bright kid my age, we all read that book and we all wanted to be like him. It was only years later I found out about just how problematic his behavior towards women was, but there wasn’t much of that in the book, or at least I don’t remember it now.
What I do remember is that as a very young physicist as Los Alamos during the Manhattan project, Feynman was partly responsible for one of the first examples of parallel computing for numerical calculations. This was long before they had actual computers, the development of which was occurring around the same time by Alan Turing at Bletchley Park in the UK, but that’s a different story.
At the time, the word “computer” meant one of the dozens of women on site that used adding machines to do numerical calculations. Feynman and his cohorts realized that each woman could do a single calculation quickly, so they arranged many different calculations to occur simultaneously using instructions written on different color cards. At one point they had dozens of different color cards flowing through the room, some with error corrections, when someone came and asked what was going on. They were hastily shooed away to keep from messing up the overall process.
Of course, nowadays the whole room would be handled by a single session with the Code Interpreter plugin in GPT-4:
GPT-4 generated Python code to create the Mandelbrot set, executed it over a small range, and generated the photo. I did that myself once back in the early 1990s on a 486-based PC and I think it took about a week. This demo took the time necessary to hit the enter key.
As for the other half of Barbenheimer, I haven’t yet seen the Barbie movie, though I’ve seen a few videos about it.
Let me just say this much: One time, when I was in high school, I went on a single date with a woman named Barbara. Nothing special about that occurred to us. Her friends, however, immediately put our first names together, and from that point on we were doomed.
Given my first name, I probably need to see the Barbie movie, but I think I can wait until it hits one of the streaming services.
Elon hits bottom, decides to keep digging
Just when you thought the bar for Elon’s behavior could go no lower, he started digging.
I’m not going to go through everything, because it’s just too depressing. I’ll summarize some of the high points, though:
On a whim (no way any of this was planned), he decided to rebrand twitter as X. He took one of the most well-established brands in the world and replaced it with a letter. A letter that can’t even be trademarked, and in fact already is encumbered by companies like Microsoft and Meta for social media applications. No doubt most readers of this publication know the emblem he chose is just a Unicode character, which means it can’t be trademarked at all.
Oh, and to make it even better, the twitter app on iPhones is still called twitter, because you can’t give an app in the iPhone store a one character name.
Just to top it all off, the guy who owned the twitter handle @x had it taken away from him by the company. They offered him some merch and a tour of their offices, but that’s it. But then again, if they’d offered him any real money, they probably would never pay up anyway.
Then, when the moderators at twitter actually suspended a user over a post that contained photos from a notorious child pornography video, Elon stepped in and reinstated him almost immediately. Clearly the name X didn’t already conjure enough porn associations for Elon.
I think there was more, too, but I can’t deal with it any more. I just can’t. I left twitter a couple weeks ago. These days I mostly just post there when a newsletter goes out, or when I have a new video available, and that’s about it. I’m sad about it, because I really felt I had a community there, and I’ve lost almost all of that.
Frankly, it hurts to care about something and have some obnoxious billionaire come in and crush it in front of your eyes, just because he can.
As for the rest of the social media landscape:
I’m pretty happy with Mastodon. No complaints.
I finally realized that on Bluesky, there are several alternate feeds that are as good or better than the basic follower tab. I’m starting to like it there, too. I now have three invites to give away, in case anyone wants one.
The Post.news app is pretty good, but I keep forgetting it exists.
LinkedIn drives more traffic to my YouTube channel than I expected, but it’s still too full of influencers and brands trying to sell you something to spend much time there.
I’m not an Instagram person, mostly because I don’t take a lot of photos. I have nothing against it, though I don’t trust Meta, but who does?
I don’t do TikTok, either. I figure I ought to at least make it a bit of a challenge for the Chinese government to dig into my phone without actually helping them.
Substack Notes are pretty useless.
I visit Facebook once a week to post my newsletter and to see if anyone else from my high school class has posted a major event. Then I remember why I didn’t keep in touch with those people and leave for another week.
I don’t really do Reddit, either. I started to, since it reminded me of the old Usenet groups I used to enjoy, but now they have their own wannabe billionaire crushing the site and moderators just to exert control and make money from an IPO.
Basically, my social media activity is now confined to YouTube and Mastodon, with a little Bluesky thrown in for seasoning. This world is changing, though, so we’ll see how it evolves over the next few months.
And Your Little Tesla, Too
As if there wasn’t enough bad Elon-related news this week, I saw this article from Reuters about how blatantly Tesla lied about their battery capacity. It seems that not only did they massively exaggerate the mileage range (something any Tesla driver knows all too well), on Elon’s orders they set up a special team to cancel service calls made by Tesla owners.
It seems when they overstated the driving range so much that many owners thought their car batteries were defective when they couldn’t get anywhere near close to that, so they tried to make service appointments. These appointments cost Tesla money, so they formed a group to call the owners, pretend to test their batteries remotely, and cancel the appointments. Then they made it so they would not accept appointments from those drivers later, even when there was something wrong.
The article goes on and on, and it was just another thing that made me mad this week. I’m not going to recount the whole thing because I don’t want to get that angry all over again.
I’ll simply say this. Most people never hear me use profanity at all. There are three situations where it happens, however:
When I’m driving,
When I’m working with computers,
When Elon Musk does yet another thing that is cruel and/or stupid.
That last condition used to be restricted to NFL Commissioner and massively entitled jerk Roger Goodell, but he’s finally been bumped from that lofty level.
Toots and Skeets and Other Posts
I’m retiring the phrase “tweets and toots” in honor of man-baby Elon. I’ll go with this title until something better occurs to me.
Zoom means remote, right?
Good question, though I’ve noticed all the social media sites demand in-person offices more than everybody else. That clearly means something, though I’m not sure what.
Good Life Lesson
I need to remember that one.
Barbenhemmer
That’s inspired. For those who don’t know, Hemmer was the chief engineer on the Enterprise during the first season of Star Trek: Strange New Worlds. Very clever.
Those who know binary
My favorite variation on that joke is:
There are 10 kinds of people
Those who know binary,
Those who don’t,
And those who didn’t realize this is actually a ternary joke.
X aka Twitter
The post referred to here is by John Scalzi on his blog called Whatever, and is called Preparing my X-it. It’s excellent, and I agree with all of it.
Speaking of that:
Here’s another related image:
Charlton Heston: You maniacs! You blew it up! Damn you all to Hell!
Oh, and the more math you know, the funnier this one is:
Yup.
So true so often
Good idea. I’ll get right on that.
Modern day Shakespeare
Imagine if Shakespeare had to deal with climate change.
Credit where credit is due
And finally,
Emotional Fruit
Have a great week everybody.
The video version of this newsletter will be on the Tales from the jar side YouTube channel tomorrow.
Last week:
Managing Your Manager, on the O’Reilly Learning Platform
This week:
Functional Java, on the O’Reilly Learning Platform
Victoria Nuland has recently been promoted to #2 in the State Department. So I wouldn't discount the possibility of perishing in nuclear war before climate change gets us all so quickly ;)
Oppenheimer the movie is based on Kai Bird's book "American Prometheus: The Triumph and Tragedy of J. Robert Oppenheimer"