Tales from the jar side: Kotlin serialization, Spring Data relationships, A movie filmed in my town, and many bad jokes
Dad joke of the week: What's the longest word in the English language? Smiles, because the first and last letters are a mile apart
Welcome, jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of September 26 - October 3, 2021. This week I finished the NFJS live event in Boston, taught a Kotlin Fundamentals class for the O’Reilly Learning Platform, and taught both a Spring Data course and an Upgrade to Modern Java course as NFJS Virtual Workshops.
I also battled a problem, which I wasn’t going to talk about, but then I saw this tweet:
That’s a bit extreme, but I get it. The world has been tough lately. I personally am doing fine overall, but I had a tough week too, mostly because of an injury. Last Friday, as I was preparing to drive to the NFJS event in Boston, I reached for something on my desk and pinched some stupid nerve in my back.
I do that every now and then, but it’s been a while, and it’s been a very long while since I’ve done it this badly. I’m writing this a week later, and my lower back and left hip are just now finally starting to calm down. It’s annoying.
I’m not looking for sympathy, and I managed to give all my presentations at the conference and teach all my courses this week, because of course I did. Or, more to the point, I wasn’t going to let some stupid back problem make me miss a class. I’ve gone over 20 years now and only missed a single teaching day (which I’m still mad about), and this wasn’t going to cause a second one.
That would be almost like missing an issue of this newsletter. If I did, half of my readers (maybe even both of them) would wonder if I was in the hospital or something.
I admit, though, it’s good thing I could do all those classes and presentations sitting down.
Being stubborn doesn’t mean there weren’t consequences, however. Everything is far more tiring when you’re in pain, and it’s hard not to get cranky*.
*See the rest of this newsletter, for instance.
I talked a couple weeks ago about how older developers can go into curmudgeon mode (seen it all, done it all, not impressed), and I struggle not to do that myself. It’s very important in both presentations and training courses to stay upbeat and positive as much as possible, or both become a real chore for the attendees. Besides, how am I going to tell my jokes if I’m all frowny face?
Speaking of which, I had a joke all ready to go for the Boston show and didn’t get a good chance to tell it. So, for your edification and potential reuse, I was going to say:
Heard about that booster shot for COVID? Around here, that’s spelled borcester.
If you tell that joke, be sure to use an exaggerated Boston accent, so you pronounce it bohrchestah. That’s kind of the point. The joke isn’t mine, of course; I saw a variation of it on Twitter. But feel free to use it if you get the opportunity and let me know how it goes.
Just for its entertainment value, here’s John Krasinski trying to teach Stephen Colbert how to speak prawpah Bawston:
I think my problem is that my accent is from a different part of town than his. Sure, I’ll go with that. After all, Mahk Wahlberg’s accent in The Depahted is very different from Matt Damon’s, yet both work way better than Jack Nicholson’s, which was horrible. In Good Will Hunting, all the accents worked except for the bizzah attempt made by Rawbin Williams, who we’re supposed to believe came from Southie? Yeah, right.
And sure, I’ll say it, it was his fault.
(The accent. Not the abuse.)
Tech Stuff
I ran into a couple of new issues for me this week during my training courses. First, I was teaching my Kotlin Fundamentals course, and as an example I went to access the Number of People in Space restful web service provided by Open Notify. That’s easy, given that Kotlin adds a readText extension function to the java.net.URL class. I normally parse that using Google’s Gson library, but Kotlin now has its own JSON serialization library so I thought I’d use that.
I remembered to add the plugin to my Gradle build file, but in class I forgot to add the required dependency.
With that added, the resulting code is:
The output at the moment is:
There are 7 people in space
Mark Vande Hei aboard ISS
Oleg Novitskiy aboard ISS
Pyotr Dubrov aboard ISS
Thomas Pesquet aboard ISS
Megan McArthur aboard ISS
Shane Kimbrough aboard ISS
Akihiko Hoshide aboard ISS
It was a lot more interesting last month, when there were three Chinese astronauts headed to their space station and SpaceX had those four tourists aboard. Still, at least it works now. If you were in my class, sorry about the missed dependency, but now you can see what it was supposed to be like.
The other major class I taught this week was Spring Data. For that course, I have a handful of classes (Quest, Task, Knight, and Castle) and relationships between them. As I always say in class, if all you have is one class and one table, everything is simple, but when you introduce relationships, life gets complicated.
(Rimshot.)
I set the relationship between Quest and Task to be a cascade delete.
When I tried to demonstrate the cascade delete in a test case, nothing got deleted. (I’d add the code here, but I’m running out of space in this newsletter. Suffice it to say, I called delete on the questRepository using the quest as an argument.)
After class I finally realized why: my test cases rollback the transaction at the end (which is a good thing!), so the deletes are scheduled but not executed. If I autowire in an EntityManager, I can call flush and see the deletes and still not mess up the shared database.
I’m still playing with all this, but I feel I should have known this long ago. At least it works now.
My Town Exists
I live in Marlborough, CT, which is a tiny spot on a map even compared to Marlborough, MA.
I usually joke that we’ve grown so much we now have two (two!) stoplights: one by the highway, and one in the center of town. Woo.
Our days of obscurity may be numbered, however. Recently the Hallmark Channel released a movie called Taking the Reins, which was filmed right here in town. Here’s a Hartford Courant article about it, from back before they changed the name of the movie (alternative, non-paywalled article here). They say about 75% of the movie was filmed at Meadowbrook Farm, which is really near where I live.
Of course, this is Marlborough. Everything in town is really near where I live. I have driven by it many times, because it’s kind of inevitable. Seriously, Meadowbrook is less than two miles away. I’ve never actually stopped there, though, because:
I am computer programmer. I believe that walls were invented to keep the outside outside, where it belongs.
I’m seriously allergic to horses, which presumably includes the stunt horses they brought in for the movie.
I wouldn’t say I’m allergic to Hallmark movies, but my blood sugar is already high enough without injecting that kind of sweetness directly into my veins.
Your mileage may vary, of course, and if that’s your thing, you do you. There’s supposed to be a scene from the local Marlborough Tavern, too. That place is okay, but overpriced for what you get. Sadler’s Ordinary is much better.
If you do visit, be sure to wave. If you decide to spend some time here (about 10 minutes), you can even visit both of our stoplights.
Because Beethoven
Put this in the category of items I should have known long ago. Apparently the song Because, which starts the 16-minute medley on the second side of the Abbey Road album by The Beatles, is directly based on the first movement of Beethoven’s Moonlight Sonata.
The story goes that John heard Yoko playing the sonata (Yoko had classical training? What were the odds of that? Does that mean if I take piano lessons I’ll start to appreciate Yoko Ono music? Not likely, but now I’m worried) and asked her to “play those chords backwards.” The rest, as they say, is history.
As an aside, every pianist likes to play the first movement of the Moonlight Sonata. The real test is whether they can handle the 3rd movement:
Yeah, good luck with that. Presto agitato, indeed.
Finally, we have a resolution to the Making Java Groovy in Middle English saga.
makyng java groovye
Last week I pointed to this web page at Amazon, which show my Making Java Groovy book, Middle English edition, published January 1, 1749. I couldn’t keep myself from ordering it.
The book arrived this week, and, sure enough, it was just the regular paperback. Nothing Middle English about it at all, sadly. I was prepared for an epic anticlimax, and I wasn’t disappointed.
A day later, I received this email:
Um, yeah. I decided to send them some feedback. I only had 200 characters, so I told them I was the author and I ordered it to see if it really was in Middle English, and that they might want to fix their web page. I did say I found the whole thing amusing and pointed them to last week’s newsletter.
We’ll see if anything comes of that. If so, look for it in next week’s newsletter.
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:
Kotlin Fundamentals, on the O’Reilly Learning Platform
Spring Data, an NFJS Virtual Workshop
Upgrade to Modern Java, an NFJS Virtual Workshop
This week: