Tales from the jar side: Good reviews for HYBHY, Head First books, and Entertaining tweets
Android is not for the delicate.
Welcome to Tales from the jar side, the Kousen IT newsletter, for the week of May 16 - 23, 2021. To those of you who subscribe to this newsletter, affectionately known as jarheads, you have my thanks. To those who do not, welcome anyway, and please consider becoming a jarhead by subscribing via this link:
After all, it’s free. But either way, I’m glad you’re here.
This week I taught two courses on the O’Reilly Learning Platform. The first was called Functional Java, and involved the functional features of the language, like streams, lambdas, and method references. The second course was week 2 of my Spring Boot in 3 Weeks training course. Also, on Friday I gave a free webinar called Upgrade to Modern Java for the No Fluff, Just Stuff conference tour.
If you like, you can watch the recording here.
Good Reviews for HYBHY
About a week ago the complete draft of my upcoming book, Help Your Boss Help You, went out to my list of reviewers. A few of the reviews have started to arrive, and they are much better than I dared hope. Some of the quotes (shown here without attribution, but they will be signed if we add them to the cover) are like, “I wish I’d had this book to read when I was starting out in the corporate world,” or “… explains the things that unfortunately many of us have had to learn the hard way,” or even “I would highly recommend it to anyone who has a long-term relationship they want to cultivate (professionally or personally … marriages included).”
I can almost see the smiley emoji no doubt intended at the end of that last one. Of course, I’ll have to see what my wife thinks about that. :)
I’m expecting at least half a dozen more reviews to wander in over the next few days, after which the job of tightening up the manuscript begins in earnest. A couple people mentioned that the beginning is a bit slow, so I need to fix that. Plus, now that the text is complete, I can see where I might add more figures or diagrams. I’m not much on the artistic side, but pictures are always a good way to break up the flow of text.
Like this:
My editor hasn’t weighed in yet. Maybe that’s a good thing.
Android Issues
Speaking of books, I’m in the middle of one myself, but as a reviewer rather than an author. The book is called Head First Android Development, 3rd edition, by Dawn and Dave Griffiths. Like all the books in the Head First series, it’s published by O’Reilly Media.
I’ve been a fan of the Head First series since the original Head First Java, by Kathy Sierra and Bert Bates, came out in 2003. Sierra studied how people learn and wrote a book completely different from everything else available at the time. The authors emphasized visual cues, and puzzles, and games (like moving code magnets onto a program with gaps in them) to help you learn a new topic. The result is clever and entertaining, and was a huge seller.
Here, for example, is an image from Head First Java:
The original book spawned a series, and the quality of the subsequent books varied. In the early 2000s I was an Adjunct Professor at Rensselaer at Hartford and taught roughly one course a semester. One year I used the book Head First Servlets and JSP in one of my classes, mostly based on the reputation.
It turned out I wasn’t wild about the book, except for a couple chapters that were new to me.
That apparently was normal. Sierra once wrote that most people’s reaction to the books was predictable: if they knew the material already, the style felt slow and distracting, but if they didn’t know it, they loved the approach. That’s exactly what happened to me — I already knew about servlets and JSPs, but I hadn’t spent much time with servlet filters, so I loved that chapter. The Head First EJB book was the first time I understood Enterprise JavaBeans, and got me through the Sun Certified Business Component Developer exam back in the mid 2000s.
I just checked at Amazon, and it turns out there are now 37 (!) books in the series, on topics ranging from Excel to Data Analysis to Design Patterns to iPhone Development. Amazon says I can buy all 37 books on Kindle for only $1004.06 (or discounted to $998.45, saving $5.61, a whole 1%).
Yeah, no, I don’t think so, but thanks anyway.
(Before I go any further, I should mention the unfortunate circumstances that led Kathy Sierra to, as the Wikipedia article tells it, withdraw from online life. Now we know how much harrassment a strong, independent woman online can attract, but back in March 2007 that was still a new thing. For no good reason, a handful of pathetic losers decided to attack her, including doxxing her (exposing her address and social security number), posting false information about her, passing around doctored images of her face next to a noose, and even sending death threats. It was, and is, appalling. Looking back, it foreshadowed the horrible Gamergate attacks that happened later, which itself anticipated the trolls associated with the Trump campaign in the 2016 election. As with so many things, Sierra was way ahead of her time, but that time in a bad way. I wish there was some way to help or at least express my support, but nothing can make up for those attacks, and if there’s any justice at all the ringleaders will roast in hell for all eternity.)
When I was seriously digging into Android development, I immediately bought the first edition of Head First Android Development. That book helped me enormously. I created a couple of videos for the O’Reilly Learning Platform on Android development, and I suppose it’s okay now to admit that without that book, I would not have been able to complete my videos. That book was the first time, for example, that I understood how to pass data from one fragment to an activity, which at the time involved:
Create an inner interface on a fragment.
Add an attribute of that interface type in the fragment.
Make the host activity implement the interface.
In the fragment’s onAttach method, which received the activity as an argument, cast it to the interface type and assign it to the attribute.
In a method in the fragment, invoke whatever interface methods you needed.
Implement the method in the activity, which can do whatever it wants, including passing that data on to another fragment.
Yikes, but without the book to explain it, I never would have gotten through the process.
I’ve been a fan of the Griffiths ever since. When I became an O’Reilly author, I asked my editor at the time to provide an email introduction, so I’ve gotten to meet them at a distance. When they decided to write Head First Kotlin, I even made it into the Acknowledgements as a tech reviewer:
Yes, that’s an old picture, and way too green for some reason, but sadly I’ll never have that much hair again.
Long-time readers of this newsletter know that one topic I come back to over and over is how much Android has changed over the years, and how it’s virtually impossible now to make a simple app that does simple things. When I heard that the Griffiths were updating their book to the third edition, I was immediately interested. If anybody can figure out a way to simplify that mess, it’s them.
About a week ago the editor sent me the first seven chapters. I finished reviewing those, and so far, so good. The only Jetpack component they’ve dealt with so far is the Navigation component. To give you an idea what that involves, when all you use are Activities, to pass a string from one to another, you:
Create an Intent.
Call putExtra on the intent with a key and the string.
Call startActivity with the intent as an argument.
On the other activity, call getIntent() and getStringExtra(key), and you’re done.
Easy peasy, lemon squeezy.
How do you work with the Navigation component? The steps are mostly shown here.
Add fragments for the start location and all destinations.
Create a host fragment to hold the navigation graph.
Create the navigation graph.
In the graph, connect the fragments to the destinations.
Add any arguments that need to be passed to the fragments.
Add the safe args Gradle plugin to your project and rebuild.
Using the generated classes (and heaven help you if they don’t get generated), pass the argument(s) to the destination by finding the navigation controller and invoking navigate() with the arguments.
The result replaces about three lines of code with multiple XML files, multiple generated classes, and code to operate between them. Yay.
Here’s a figure from their book:
Believe it or not, that’s a good explanation of what you need to do.
Is the result better? Probably. Is it simple, in any possible definition of that term? Hollow laugh. It took the Griffiths two full chapters to work through all that. They did a good job, of course, but seriously, how is this an improvement?
So far I’ve been through seven chapters, and we haven’t yet talked about ViewModel, LiveData (or the new SharedFlow and StateFlow), Room, Retrofit, view and data binding, WorkManager, coroutines, or the new Jetpack Compose, which promises to change everything yet again. I don’t envy their task.
BTW, after Google I/O this week I was browsing some Android articles when I came across this one, about Migrating from LiveData to Kotlin’s Flow. It has a section with the header, “Flow: Simple things are harder and complex things are easier.”
Truer words were never spoken.
A Quick Note on the Spring Boot Upgrade
My Spring Boot in 3 Weeks course will be impacted by the fact that Spring Boot changed versions this week to 2.5.0. I looked at the release notes, and the first thing they mention is that the SQL script datasource initialization has changed. Instead of using properties like spring.datasource.*, now they’re called spring.sql.init.*. There are lots of other changes, too, but those potentially impact everything I do when I teach that course.
As it turned out, however, when I updated our existing app to 2.5.0, everything still worked as before. Whew. I’ll have to update this week’s slides, though.
On The Lighter Side
Here are some tweets and images this week that are a bit more pleasant than all that. First, a nice lament:
Yeah, I get that.
Speaking of Kotlin:
Delicate? Did they say GlobalScope is now delicate? They did, and they mean it. If you decide to use it, you have to mark the usage with @OptIn(DelicateCoroutinesApi::class). Seriously. So far I haven’t been able to come up with a good gag about that, but it does pretty much speak for itself.
Maybe this is close:
Totally unfair, but true nevertheless. And yeah, I’m delicate.
Now that’s just mean. Funny though.
That’s an old joke, but still funny.
Finally, if you spend any time on Slack, you’ll appreciate this:
I’ll never not see it that way now.
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:
Functional Java, on the O’Reilly Learning Platform
Day 2 of Spring and Spring Boot in Three Weeks, ditto
NFJS Webinar: Upgrade to Modern Java
This week:
Introduction to Gradle for Gradle, Inc.
Day 3 of Spring Boot in 3 Weeks, on the O’Reilly Learning Platform