Tales from the jar side: MongoDB and Docker, Two Messages for your manager, and New Release No More
Best tweets this week: (1) Stores and restaurants ought to say you can't speak to the manager unless you show your vaccine card, and (2) Imagine Roy Kent hosting Jeopardy!
Welcome, jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of August 22 - 29, 2021. This week I taught a Basic Android course on the O’Reilly Learning Platform and a private Spring framework course.
If you’re not one already, please consider becoming a jarhead by subscribing to Tales from the jar side using this link:
Mongo Only Pawn
About a week ago, I taught a course on Reactive Spring on the O’Reilly Learning Platform. The term reactive means the system is based on an observer-observable model, where a subscriber listens for events from a publisher, which later sends them. It’s an asynchronous model, which is always hard to understand and worse to debug.
One of the surprising issues that comes up when describing reactive systems is that relational databases are inherently synchronous. That means when you invoke an operation involving a database — the so-called CRUD operations, for Create, Retrieve, Update, Delete — the system blocks until it gets a response. When you’re trying to design a system that registers calls and only responds later, that’s a problem.
As an aside, Spring has a specification called R2DBC, which sounds like it ought to involve persistent droids but actually stands for Reactive Relational Database Connectivity. I don’t use it, even in class. Even though it’s at version 1.3.4, I’m not convinced it’s ready for prime time. More to the point, while Spring Boot provides sample reactive drivers for several relational databases (MySQL, Sql Server, H2, Postgres, and even, believe it or not, Oracle), I don’t think VMware (the company behind Spring) wants to maintain the drivers themselves. I think they’re more interested in providing a specification with a few samples, but having the various database vendors create and update the drivers. Even though the spec went to version 1 last year, I’m not seeing wholesale adoption by the database vendors themselves, and I’m not convinced that’s going to happen. Just because you create a spec, doesn’t mean anybody has to follow it.
So when I teach my Reactive Spring course, I use one of the so-called NoSQL databases, which have official reactive drivers. The one I like is called MongoDB. It’s a document database whose native storage is based on BSON, or Binary JSON, making it ideal for working with RESTful web services. My reactive examples combine Spring for the reactive services and MongoDB for the persistent storage.
In a nice demonstration of a sense of humor, the Mongo database is in fact named after Mongo from the movie Blazing Saddles.
Or, if you prefer a YouTube clip:
Mongo in the movie is played by Alex Karras, an NFL Hall of Fame player who became an actor after he retired. Clearly, the role of Mongo was the peak of the Alex Karras ouvré.
I liked using MongoDB partly for this reason, but also because Spring Boot provides an “embedded” driver for testing. That means you can do tests based on Mongo without actually installing the database. The official Maven coordinates for the embedded MongoDB driver are:
Yes, the group id and the artifact id both start with de.flapdoodle. The de part means the German language, and flapdoodle translates to foolish nonsense, more or less. I suppose those crazy Germans just can’t resist a good joke sometimes.
I’ve taught this course many times, and everything went fine in my class a week ago until the very last exercise. Unlike the tests (which worked — thank you, flapdoodle, whoever you are), the last exercise required me to have an actual running instance of Mongo on my machine, which I installed with the Homebrew package manager.
For the first time in years that failed, because my local instance of Mongo wouldn’t start. That never happened to me before, and I wasn’t able to fix it during class.
This week I spent a lot of time digging into that, with no real success. This, sadly, is not unusual in software, where something that worked for years suddenly stops working because of version changes. I tracked it down to a permissions issue between Mongo and the latest macOS operating system (I’m on Big Sur, but the problem may be older than that). Unfortunately, none of the solutions I found online fixed it.
That led me to another idea that takes a bit of explanation for non-IT people: Docker containers.
Standardizing Shipping and Docker
Back in March, you may recall the Ever Given, the massive (400 meter long) container ship that got stuck in the Suez Canal, blocking it to all traffic for weeks.
The Ever Given is a container ship. As you can see from the photo, the ship carries standard shipping containers, the invention of which revolutionized the shipping industry (see this link for a nice history). Companies rent and fill containers, which can be loaded optimally on container ships and transported to ports all over the world.
The container itself in IT would be called a layer of indirection — something between what I have and what I want. My cargo goes inside the container, and the ship transports containers. The container is the layer of indirection between my stuff and the boat.
Oh, and just for fun, here’s a picture of the Blue Marlin, a ship that ships shipping ships. It’s not really relevant to my point, but it’s a cool picture anyway.
This situation comes up in computer science all the time. In fact, one axiom of computer science is:
Every problem in computer science is solved by adding a layer of indirection.
(The more humorous version of that phrase is: Every problem in computer science is solved by adding a layer of indirection, except for the problem of too many layers of indirection. I’m not sure I believe that, though. I think I could add a layer of indirection that simplified the layers of indirection, but that might trigger Inception, so let’s not go there.)
Applied to the software world, there is a software tool called Docker, which lets you create and populate containers. The good part about Docker is that using it, you can download a container that holds the software you want, generate an image from it, and use it in your system, all while avoiding ever installing the original software.
Docker has been out for a while, but the problem with layers of indirection is that while they help flexibility and maintenance, they’re hard on complexity. You may have heard the term spaghetti code for code that is a tangled mess of execution paths? Well, an architecture with too many layers is often called lasagna code.
My problems with Mongo, however, reminded me of this excellent Docker in IntellIJ IDEA YouTube video provided by Dalia Abo Sheasha of JetBrains, the company behind the IntelliJ IDEA environment:
I watched that, and her companion video Intro to Docker [with Java Examples] about a month ago when it came out, and in it, one of Dalia’s examples is setting up a MySQL instance inside a Docker container. I thought that if I could set up something similar for MongoDB, I wouldn’t need to figure out how to fix the software installation.
That took me a fair amount of effort. I guess I hadn’t really gotten the differences between containers and images, and while the Docker Desktop program created an image for me, it turned out not to be helpful. I eventually created my own image, and then — this was the real key — added a port binding to the container that exposed the default port for Mongo, and everything worked.
So thanks, Dalia. :) Now I can access a Docker container holding an instance of MongoDB running through my local Docker Desktop installation, and I don’t have to figure out why the original stopped working or how to fix it. It’s all good. Since I’m teaching a new Spring Data course in a few weeks, I’ll see if I can leverage what I know to set up a container of my own that students can install for the course, but we’ll see if I can figure that out in time.
The Question None Of You Are Wondering About
Last week I had a section in the newsletter called The Question You’re All Wondering About, which described how my book Help Your Boss Help You is doing and my marketing activities around it. I meant to turn that into a joke, but the newsletter got long and I forgot to get back to it. Anyway, let me do the opposite this week.
There were a couple of developments regarding the book this week. One is that I released another Medium article through the Pragmatic Programmers publication, entitled The Two Messages To Give Your Manager. The article starts out like this:
Well, there’s a problem. I did get that notification from Medium about being a top writer in Business. When I dug into it, I discovered that they were referring to a list of fifty writers, where I appeared in position #48. Unfortunately, however, between the time I wrote the article and when it was published, I dropped off the list. Sigh. Maybe this new article will be so popular I’ll get back on it, but I’m not going to worry about it.
For the record, the two messages to give your manager are:
I got this, and
I got your back
I discuss both of them in detail in the book. The former is an expression of self-confidence and a willingness to take responsibility for any tasks assigned to you. The latter is about understanding that to the outside world, we’re a team, and I’ll back you up when things go wrong. Feel free to read the article for details.
The other event of note had to do with my obsession with how the book is doing on the New Release lists at Amazon. Here’s a picture from a couple newsletters ago:
I’ve been watching the book move between #1 and #4 in the New Releases list for both Business Communication and Business Ethics for weeks now. In the back of my mind, however, was the big question: How long does Amazon consider a book a new release? Because once that’s over, I’m done. On the Best Sellers lists for either topic, I think I only broke the top 100 once.
Here are the current product details, from the Amazon page:
(I think a week ago I was in the top half-million, so that number jumps around a lot.)
As you can see, according to Amazon, the release date for my book was July 27, 2021. This week, on Thursday, August 27, the book vanished from the New Releases lists. It’s gone now. So much for that. To be honest, I’m a bit sad about it.
On the plus side, the book is now available as a Kindle book as well, and I just now thought to check the product details on that version:
That’s not so bad. Plus it’s got a new category (Workplace Behavior, whatever that is). I’ll take it.
The next step is to publish the audio book. I’ve been fixing some minor audio issues on that, and likely will release it before the next newsletter. I’ll let you know.
For jarheads only
As a reminder, jarheads can get the ebook versions of Help Your Boss Help You at the Pragmatic Programmers using the coupon code 7bc968c446 at checkout for a 35% discount. The code is good until the end of September, 2021.
If you’re not a subscriber, that’s fine. You get to use the coupon too.
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:
Basic Android Development, on the O’Reilly Learning Platform
Final week of a Spring course for a private client.
This week:
Deep Dive: Spring and Spring Boot, an NFJS Virtual Workshop