Tales from the jar side: Good enough answers, Java Suppliers, and my Epic Adventure Outside
Jenny Agutter should have won an Oscar for Logan's Run for her costume alone
Welcome to Tales from the jar side, the Kousen IT newsletter, for the week of April 26 - May 3, 2020. This week I taught a course in Functional Java, worked on my Managing Your Manager book, and had an Epic Adventure Outside.
Wednesday morning dawned bright and beautiful (for a change), despite the fact that my cable modem/router died the night before. I woke to discover that it passed away just before midnight. Even though it was plugged in and had given me years of faithful service, nothing worked any more. No lights, no nothing. It was stone dead. Deceased. It had passed on. Bereft of life, it shuffled off its mortal (yeah, whatev, go with it) coil and joined the choir invisible.
This was an ex-router.
In the midst of a pandemic, that’s not good. Since my entire business — if not the vast majority of my life — is lived online these days, I needed to do something fast. I checked Amazon, only to discover to my horror that their earliest delivery date for a decent router was next week.
Ugh. I vaguely recalled, however, that in the Before Times there were rumors of actual physical stores that carried actual physical equipment. That meant it was time to venture Outside.
Wow, Hartford has really changed.
The prospect was not appealing. I’m an IT person, after all, so I’m reluctant to expose myself to that weird yellow ball in the sky on the best of days.
Yes, those are from Logan’s Run. Can I get an “OK, Boomer”?
Nevertheless, I girded my loins and prepared to join the rest of the hunter/gatherers.
Don’t worry. I tied up the mask when I got to my destination
At the end of my journey, I found Sanctuary.
Of course, it’s not like I could go inside or anything.
Fortunately, they provided curbside pickup for such emergencies.
Ultimately, I was successful.
The prey. Harpoon not shown.
Hooking it up wasn’t difficult. The challenge was getting Xfinity to recognize the new router, which it stubbornly refused to do. The strange part is that after a few minutes, it started working anyway. Comcast still claims they can’t see it, though. Since I was unwilling to deal with a service call, I’m just going to live with it and see what happens.
Ultimately, a banquet was held in celebration.
The traditional celebratory feast of salami on a toasted bagel with coffee. Smells like victory.
The real lesson, as always: money can make a lot of problems go away. Which reminds me, I need to make another contribution to my local food bank.
Speaking of the current pandemic
So many states in the U.S. are starting to reopen, despite the lack of widespread testing, contact tracing, or available treatments or a vaccine. I live in Connecticut, one of the hardest hit states so far (partly because of our proximity to New York; partly because of our aging population; partly because we’ve done more tests than most), and even our governor has announced a limited opening of non-essential businesses on May 20.
In response, I saw this tweet:
Yup, pretty much. I guess we’ll see the results in June. My family is still healthy at the moment, and we’re going to continue to err on the side of caution. Fortunately most of my business is online at this point, so I can afford to do that.
Managing Your Manager
This week I’ve been writing in earnest. This is partly because of Laurie Penny (here is her Facebook page and her twitter feed), an author and journalist I’m happy to support on Patreon.
Her writing is eminently quotable. Here’s a recent twitter post from her, pointing to an article she wrote for Wired.
It’s a really good article. I’ve been seeing quotes from it in several places, some sadly without attribution.
Whatever you might think of her politics, she’s a fantastic writer. Because she’s facing her own deadlines, she decided to host Laurie’s writing sprint quarantine club on Zoom. Everyone is welcome. There’s not much interaction. After an initial greeting, everybody just writes on their own, with occasional breaks. I feel like everyone is writing near each other, as though we were all in the same coffee shop but not talking.
I was reluctant to join because I didn’t know anybody, but eventually I did so anyway. It’s been far more productive than I expected. This week I’ve revised a couple of chapters in my Managing Your Manager book and completely rewritten my “good enough answers” chapter, and I hope to keep going for a few days. We’ll see.
The concept behind good enough answers is the following:
A good answer today is much, much better than a great answer next week.
This is completely contrary to what we learn in school, where we are rewarded for giving a complete answer, quickly, showing all the steps the way the teacher wants to see them. That works in school, but not in the business world. In school, when you’re asked a question, the teacher knows the correct answer and expects to see it in a preferred way. In the business world, when somebody asks you a question, it’s because they’re stuck and they need help.
I talk about all of that, and provide a template that allows you to give a good enough answer without disrupting your life more than necessary. Responding quickly is a great way to build the constructive loyalty relationship.
I expect that chapter will be part of my upcoming three chapter review, which I’ll discuss in a future newsletter. The next time I’m running the associated training course on the O’Reilly Learning Platform is May 14. I’d like to see how much of a complete draft I can complete by then.
Suppliers in Java
I have to admit that I’m surprised that my Functional Java course still draws such a big audience, given that Java 8 (when streams, lambdas, and method references were added to the language) came out over four years ago. I’m glad, though, because I still enjoy talking about the concepts. I especially like talking about more advanced features, like deferred execution using suppliers.
A simple example is available in the java.util.logging.Logger class in the standard library. That class has an overloaded info method, one of which takes just a String and the other of which takes a Supplier<String>. If you dig into the implementation of the supplier version, you see that the supplier is only evaluated if the message is going to be seen. If your message is trivial it doesn’t make a difference, but if creating the message is a complex process, all you have to do when you invoke logger.info() is to add () -> in front of your message and you only evaluate the message if you need it.
The Optional class has something similar. The orElse(T) method returns a value if the optional is not empty and returns the argument if it is. There is also an orElseGet(Supplier<T>) version, that only creates the default if the optional is empty.
Heck, even JUnit 5 gets into the act by allowing all the methods in the Assertions class to have as their last argument either be a String or a Supplier<String>. The latter is used to evaluate the error message lazily, only if the assertions do not pass.
This technique is very useful, but it’s easy to miss until someone shows it to you. Of course I have a bit about it in my Modern Java Recipes book.
The group was engaged and enthusiastic, and some of them even decided to subscribe to this newsletter. For those who did so, welcome. :)
Last week:
Functional Java, on the O’Reilly Learning Platform
Lots of writing on Managing Your Manager
My router/modem adventure. Renew!
This week:
Reactive Spring, online on the O’Reilly Learning Platform
Kotlin and Spring, ditto
Spring and Spring Boot, same
As much more writing as I can manage (Managing Your Manager pun intended)