Tales from the jar side: A conference talk, Audiobook progress, Java Suppliers, and a StackOverflow survey that shows developers are still really young
The Naming is Hard IntelliJ plugin looks awesome, but I ran out of room to talk about it. Check for it in the Marketplace tab in Preferences.
Welcome, jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of August 1 - 8, 2021. This week I taught the first day of my Spring and Spring Boot in 3 Weeks course and my regular Functional Java course on the O’Reilly Learning Platform, I recorded an episode of the GOTO podcast, and I gave a presentation at the online International Developer Career Day conference.
If you’re not one already, please consider becoming a jarhead by subscribing to Tales from the jar side using this link:
International Developer Career Day
A couple weeks ago, Bruno Souza sent a message to the Java Champions email list, of which I am a member. Here’s a portion:
I know you are tired of online conferences...
Would you consider one that is not really a conference?
On August 6th and 7th, we will celebrate the
International Developer Career Day!
The whole focus is to have interactive conversations with developers.
Yeah, you can give a talk if you want, but you will have your own
room, for as long (short long or long long) as you want, to interact
with developers from all levels, to help them push their careers
forward.
Imagine an unconference where you moderate your own room, with a topic
of your interest. You can give a talk, answer questions, tell stories,
moderate a discussion, run a fish bowl...
Would you consider that?
Bruno is known as the “Brazilian JavaMan,” and is president and co-founder of SouJava, the Brazilian Java Users Group, which is largest such group in the world (the Wikipedia page on it claims over 40,000 members!). I met him once at a JavaOne conference, but I seriously doubt he remembers me.
His conference, however, fit my book Help Your Boss Help You perfectly. Most people who comment on the book say they wish they’d learned its lessons years ago, so it’s a natural for developers trying to push their careers forward. Besides, I have a version of a talk based on my book that I can fit into one hour, and I’m fine with doing remote talks, so it’s all good.
My talk was scheduled for last Friday (Aug 6) at 2pm. We did various checks to make sure that the remote system was working well, and off I went. Bruno later said that there were over 600 attendees in both days, with at least a couple hundred the first day. I didn’t pay attention to how many were in my session, but I think there were a good number based on the questions and comments.
The talk went well, and I gave out the slides and a coupon code for the book (the same one jarheads have been using, which is included at the end of this issue).
HYBHY Marketing
Speaking of Help Your Boss Help You, as you may recall that last week the book was in the top five in the New Releases section of the Business Ethics category at Amazon. This week the book hit #1 in New Releases in both Business Ethics and Business Communication.
I’m happy about both, obviously, but I really prefer the Business Communication (I so desperately want to make that term plural, but so be it) category. After all, Business Ethics sounds like an oxymoron, like military intelligence, or jumbo shrimp, or (sigh) working vacation.
During the week the book dropped down to #4 in each category, but today, as I was writing this newsletter, it jumped back to #1 again. Yay!
I can see that monitoring this is going to be quite the joyride, but at least it will be eventful, with many colorful sites to see along the way before I crash into an embankment somewhere.
(Btw, the book is also #3 in New Releases in Management. I can’t believe it never occurred to me to look there, too.)
My Medium article this week was about violating the chain of command:
I have a section in there about Mark Cuban, which we had to tone down a lot because he is notoriously litigious. I tried to argue that the best thing that could possibly happen for my book was for Mark Cuban to call me out in public, but no such luck, at least so far.
Audiobook Is A Go
Another significant event that occurred this week is that the Pragmatic Programmers (the publishing company for HYBHY) finally managed to convince Audible that I have the rights to the audiobook version. That means I was able to “claim” the book at Amazon (Audible is now a division of Amazon) and set up the initial project there. In case you’re interested, I opted for non-exclusive distribution rights, which means my royalty rate from them will be lower, but I can distribute the book anywhere I want. Since I’m much more interested in building an audience than making lots of money, that works for me.
This week I managed to record an additional two chapters, so that means eight of the ten chapters are all set, at least as far as the minimum audio requirements are concerned. That means I have two chapters to go, along with the opening and closing credits, and any additional post-processing needed before release.
I’m headed into a very busy part of my schedule, but I still hope to have the audiobook in production by the end of August.
Suppliers for Lazy Evaluation
I’ve been a bit wrapped up in the book release lately, but I’m still doing technical work. During the Functional Java course this week, I discussed how the Supplier interface, added to the java.util.function package in Java 8, is often used for lazy evaluation of objects. I thought I’d include a couple of examples of that here.
The java.util.function.Supplier<T> interface looks like:
It has a single abstract method called get() that returns a reference to an instance of T.
To see how it is used, consider the JUnit 5 testing framework. If you look in the Assertions class, you’ll find three versions of assertTrue:
The first version checks its argument and prints an error message if it isn’t true. The second one lets you add an error message to include if the test fails. The third one changes that second argument from a String to a Supplier<String>.
If the error message is a simple, hard-coded string, then the difference between the latter two versions don’t really matter. But if creating the error message is an expensive process for some reason, you only want to do it if you need it.
Here’s my demo to illustrate the differences:
The private method getErrorMessage prints out a message to say it has been called before returning the error message. In the showError test, the first call to assertTrue invokes the getErrorMessage regardless of whether the first argument is true or not. But simply by adding parentheses and an arrow, as shown in the second call to assertTrue, the argument changes from a String (returned by the getErrorMessage method) to a Supplier<String>. If you dig into the details of the assertTrue source code (which we do in class), you’ll find that if the boolean is true, the get() method on the Supplier is never called.
The docs refer to this as lazy evaluation of the error message, meaning the message is only formed if the assertion fails, and is one of the more common usages of suppliers in the Java library.
The example also shows that the logging methods in the java.util.logger.Logger class (which have the odd names severe, warning, info, config, fine, finer, and finest) are all overloaded to take a String or a Supplier<String>. That means the second to last line in the test above forms the log message even if it won’t be seen, but the last line checks first to see if it’s “loggable” and skips it if not.
In case you’re interested, another example in the library comes in the java.util.Optional class.
The orElse method returns the value held by the Optional if it exists, and if not, returns the argument. The orElseGet method, on the other hand, takes a Supplier<T>, and only forms the necessary value if the Optional is empty.
Suppliers are one of the four major categories of functional interfaces added to the java.util.function package in Java 8. The others are Consumer, which takes a value and returns nothing, Predicate, which takes a value and returns true or false, so it’s used primarily to filter a stream, and Function, which accepts a value of type T and returns a value of type R, and is used in the map method on Stream. After looking a streams, most developers understand the reasons for those. The goal of Supplier is often not obvious until somebody points out an example, like the one in this section.
Miscellaneous Tweets
Natalie Wynn, better known as ContraPoints, has new video out:
Honestly, this is one of her best. I loved the comparison of the Salieri/Mozart relationship to that between Squidward/Spongebob Squarepants. It really works once she explains it. The only issue with the video is that it’s an hour and 45 minutes long, but it never dragged for me.
The StackOverflow survey for 2021 is now available:
I’m still digging into the results, but the one I couldn’t help checking right away is the average age of professional developers:
Yup, developers still skew very young, at least from my point of view. I’m comfortably in that 2.25% section.
Finally, I had my WORST EXPERIENCE EVAR with autocorrect this week. Helen Jo Scott took her turn this month putting together the Java Annotated Monthly:
I thought she did a great job, and not just because she included links to a couple of my Medium articles. :) Unfortunately, when I tried to tell her so right before one of my classes started, autocorrect reared its ugly head:
Fortunately, she understood:
For jarheads only
If you are interested in my book Help Your Boss Help You, use the coupon code 7bc968c446 at checkout for a 35% discount on the ebook versions. The code is good until the end of September, 2021.
BTW, if you’re not a subscriber and you’re reading this anyway, 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:
Week 1 of Spring Boot in 3 Weeks, on the O’Reilly Learning Platform.
Functional Java, ditto.
Recorded the GOTO podcast, to appear in September.
Recorded two more chapters for the audiobook of HYBHY.
This week:
Latest Features in Java, an NFJS Virtual Workshop.
Week 2 of Spring Boot in 3 Weeks, on the O’Reilly Learning Platform.
Day 1 of an online private Spring course.
Play chess at the Continental Open, 7 round Swiss-System tournament held in Sturbridge, MA, on the Connecticut/Massachusetts border. If next week’s newsletter is a bit delayed, you’ll know why.