Tales from the jar side

Share this post
Tales from the jar side: Your weekly Steph update, Scrambling to fix a training class, Terrible maps, and a health issue
kenkousen.substack.com

Tales from the jar side: Your weekly Steph update, Scrambling to fix a training class, Terrible maps, and a health issue

My network access was inconsistent, so I moved my modem to where I keep my horses. Now I have stable wifi (Rimshot).

Ken Kousen
May 22
Share this post
Tales from the jar side: Your weekly Steph update, Scrambling to fix a training class, Terrible maps, and a health issue
kenkousen.substack.com

Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of May 15 - May 22, 2022. This week I taught a Java Testing with JUnit 5 course, a Functional Programming in Java course, and a Reactive Spring course, all on the O’Reilly Learning Platform.

Regular readers of this newsletter are affectionately known as jarheads, and are far more intelligent, sophisticated, and attractive than the average newsletter reader. If you wish to become a jarhead, please subscribe using this button:

As a reminder, this message is truncated in email, click on the title at the top to open it in a browser tab formatted properly for both the web and mobile.

Your Steph Update

I was tempted to start this week’s newsletter with a poll:

Why do you read Tales from the jar side?

  1. For the deep insights into the world of teaching and development using Java and related languages.

  2. For keen observations about Life, the Universe, and Everything*.

  3. For the funny tweets included at the end.

  4. Read it? The newsletters accumulate in my email box, but I didn’t know I was supposed to actually read it.

  5. To find out how many free throws NBA legend Steph Curry missed.

You and I both know the real answer would overwhelmingly be the last one. So let’s get to it, shall we?

(*And yes, the Answer to the Ultimate Question of Life, the Universe, and Everything is … 42. Sorry about the spoiler for a book that came out about 40 years ago.)

Steph Curry On The Line

Is Warriors' Stephen Curry playing tonight vs. Clippers? | Sporting News  Canada
They call him the Baby-Faced Assassin. Seriously.

Game 1 of the Western Conference Finals was Wednesday night, and Steph Curry, the Greatest Free Throw Shooter in the History of the World, missed his first two free throw attempts (!) and three of his first four (!!). He had a lousy first half, but woke up late and finally found his form. At least he played better than his fellow star, Klay Thompson, who seemed to miss his shots or turn the ball over every time he touched it. Steph wound up with 21 points, and finished 4 of 7 from the line.

With that build-up, you’ll probably be surprised to hear that Golden State won 112 - 87, but somehow that’s what happened. The Warriors led most of the second half by 25 or more.

Game 2 was played on Friday night. This time the Warriors fell behind by as much as 19 in the first half, and even though Steph was playing well, it looked like they were going to get run out of the building. Somehow they chipped away and chipped away, and were only down by 2 at the start of the 4th quarter. They eventually won, 126 - 117, and Steph wound up with 32 points. He also, I’m happy to say, went 4 of 4 on his free throw attempts.

During that game, it got so bad the announcers mentioned that Steph making his free throws was no longer an automatic, and that he was shooting only 80% for the playoffs. Maybe that was the reverse jinx that got him going. Whatever, I’ll take it.

Game 3 is tonight (Sunday, May 22) in Dallas, so more about that next week.

Set-Up Problems

Late last year, I bought a new Mac laptop, with the super-awesome M1 chip. The goal was a seemingly unreachable dream — I wanted a machine that would let me be on a Zoom call without running the fan at high volume. To my considerable surprise, that actually worked. I’ve been using the new machine for months now, running IDEs and browsers and Zoom (oh my), and I’m not even sure this computer has a fan. Sweet.

The transition to a new machine is always a bit of an adventure, however. I have to reinstall a lot of software and move the licenses over, and check out a range of projects from my GitHub repository, and so on. A lot of what I do is stored online, so it’s less trouble than it could be, but I always worry that I’ve forgotten something.

Sure enough, this week I discovered I left something out. I was running my Reactive Spring course on Friday, which uses the MongoDB database. Mongo is a so-called NoSQL (which stands for Not Only SQL), document-based database, named after (I assume) the eponymous character from Blazing Saddles.

MONGO ONLY PAWN IN GAME OF LIFE - mongo | Meme Generator
Truly the peak of the Alex Karras ouvre

The reason I use Mongo during class is that it comes with a reactive database driver, which is available through the Spring Boot Initializr. Until relatively recently, relational databases didn’t support reactive, asynchronous calls, so in order to run the class, I needed to use a NoSQL one, and since the native format inside MongoDB is BSON (binary JSON), it’s a natural for restful web services that exchange JSON data.

The problem is, to do the class, the students have to install MongoDB. MongoDB has a free, community edition, but that’s still an extra step. I’ve been toying with moving to the R2DBC* project, but other than doing the simple Spring Guide around it, I hadn’t done much yet.

*As I joke during class, R2DBC stands for Reactive Relational Database Connectivity, which has nothing to do with the droids you’re looking for.

You will never have a 21st birthday again happy birthday andrew - Star Wars  Problems - quickmeme
R2D..BC, get it?

I have a lot of material on reactive Spring, and I was forced to rush at the end, which is not unusual for that class. I ran the tests with the embedded version of MongoDB, which worked just fine — almost. It turns out that now, to use the embedded version, you have to add the following line:

spring.mongodb.embedded.version=3.4.5

to the application.properties file. That didn’t used to be necessary, but at least I was able to figure out that problem pretty quickly.

Then I tried to do the last exercise, and discovered — you guessed it — I’d forgotten to install MongoDB. I had less than ten minutes left in class, so the question was, could I fix everything on the fly, with everybody watching?

I tried to do the Homebrew install (that’s a Mac thing), but unfortunately I installed mongosh, the interactive shell, rather than mongo-community, which is what I needed. Then I figured I’d see if I could switch to R2DBC using the H2 database, which I reviewed that morning but hadn’t yet used on my exercises.

To make a long story short (I know, too late), I didn’t quite make it. I switched to an Integer type for the primary key, and I added the required dependencies for R2DBC to my Gradle build file and re-synchronized the project. I switched the Spring Data interface from extending ReactiveMongoRepository to extending ReactiveCrudRepository, and even added a schema.sql file to my src/main/resources directory to create the necessary table. It didn’t quite work. I figured out later that I needed to add a DROP TABLE statement to the beginning of the SQL file, because it wasn’t able to reset what I had without it.

Fortunately I was able to switch to my solution of the Spring Guide mentioned above, which I streamlined from their answer, and I was able to add a controller with a couple of finders. That, at least, worked.

The problem is, did the students learn anything, other than the fact I can code very quickly when I have to? I don’t know. I’m still rather annoyed at myself for not realizing I didn’t already have MongoDB installed, but so be it. What I really wanted to do to fix things was use the testcontainers project to use the cloud provider, but that needs slightly more code than I was comfortable trying to throw together with time running out.

Before we run this class again, I really need to port everything to R2DBC, because that’s working now and is far simpler than the alternatives. Oh well. Lesson learned.

Hello, Mockito

The other big activity I’ve been working on this week has been getting the beta version of my latest book, Mockito Made Clear, ready for release. As part of a rewrite of the first chapter, I decided to add a “Hello, World!” type of application that needs Mockito.

Here’s the greet method inside my HelloMockito class, which needs to be tested:

The idea is that the class has two dependencies:

  • PersonRepository, which has methods to save and find Person instances, and

  • TranslationService, which translates the greeting string to whatever language the user wants.

Both of those need to be mocked in order to test the greet method. I included a test that uses Mockito in the first chapter, which is basically a teaser for the rest of the book. Hopefully that will be clear to the readers. We’ll see.

More about that soon. The book is scheduled to go “beta” in early June.

Tweets And Random Stuff

Terrible Maps

The twitter feed @TerribleMaps broke 700,000 followers, so to celebrate they asked people to retweet some of their favorites. Here are a few I like:

Twitter avatar for @TerribleMapsTerrible Maps @TerribleMaps
Population per capita By @JakubMarian
Image

September 27th 2021

1,558 Retweets12,903 Likes

Yup, that works.

Twitter avatar for @TerribleMapsTerrible Maps @TerribleMaps
Nice people
Image

October 7th 2021

3,060 Retweets28,116 Likes

I guess I’m not Nice, but I already suspected that.

Twitter avatar for @TerribleMapsTerrible Maps @TerribleMaps
Electricity consumption in Europe in 1507
Image

September 11th 2017

23,217 Retweets89,254 Likes

I don’t know where the data came from, but that seems reasonable.

Dad Joke

Twitter avatar for @ArfMeasuresJon @ArfMeasures
Wife: I want a divorce because your enthusiasm's turned into bitter sarcasm Tony the Tiger: great

September 4th 2020

524 Retweets4,439 Likes

Sad if true.

Your NFT Laugher Of The Week

Twitter avatar for @ChessProblemMrDodgy (CEO of Chefable) @ChessProblem
nfts are morally superior to cryptocurrencies because they are openly stupid

May 17th 2022

4 Retweets120 Likes

Says it all.

If I Only Had A Heart

My Grandfather, The Tin Man | Hometowns to Hollywood

Finally, in what can only be described as burying the lede, I need to mention that I’m having medical care inflicted upon me once again this week. Back in the middle of March, I spent a week in the hospital suffering from what they called diabetic ketoacidosis, which showed some small impact on my heart. During that time, I had an echocardiogram done and a stress test. Apparently the test showed a small area of the heart that was “unclear,” meaning it might possibly be a problem, though an easily repaired one if one exists at all.

As a result, on Friday this week I’m going back into the hospital for what they call a heart catheterization (angiogram) procedure.

(Boy, I never want to hear the word catheterization in any context whatsoever. Nothing good can come of that.)

If they find a blockage, they’ll insert a stent, and problem solved. If not, we’re good. This is considered routine surgery, and I should be able to go home the same day. The risk of complications is extremely small.

This is one of those cases where knowing a bit about statistics can be helpful, but it’s hard not to be a little nervous, not to mention the annoyance of losing a least a day right before Memorial Day weekend. I wouldn’t mention it here at all, but I got so many kind replies last time, I thought you might like to know. I will most certainly blame any delays on getting out next week’s newsletter on this, regardless of whether it’s true or not.

Share Tales from the jar side

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:

  • Next Generation Java Testing with JUnit 5, on the O’Reilly Learning Platform

  • Functional Programming in Java, same

  • Reactive Spring and Spring Boot, also same

This week:

  • Mockito and the Hamcrest Matchers, on the O’Reilly Learning Platform

  • Getting Started with Spring and Spring Boot, same

  • Modern Java: Functional Programming, an NFJS Virtual Workshop

Share this post
Tales from the jar side: Your weekly Steph update, Scrambling to fix a training class, Terrible maps, and a health issue
kenkousen.substack.com
Comments

Create your profile

0 subscriptions will be displayed on your profile (edit)

Skip for now

Only paid subscribers can comment on this post

Already a paid subscriber? Sign in

Check your email

For your security, we need to re-authenticate you.

Click the link we sent to , or click here to sign in.

TopNewCommunity

No posts

Ready for more?

© 2022 Ken Kousen
Privacy ∙ Terms ∙ Collection notice
Publish on Substack Get the app
Substack is the home for great writing