Tales from the jar side: Android, Spring MVC, and a Groovy Podcast
Also contains a story about Groovy Vampires and trying to sell actual books in actual bookstores
Welcome to Tales from the jar side, the Kousen IT newsletter, for the week of Feb 2 - 9, 2020. This week I taught an updated version of my Basic Android course, as well as a Spring MVC course for the first time. I also got involved in a project to convert some of my Kotlin Cookbook recipes into the katacoda system now provided by O’Reilly Interactive Learning, which I’ve been referring to here as Safari. At the end of the week, I finally recorded another episode of the Groovy Podcast.
Bookstore Blues
Before I get to that, however, look at this picture:
First appearance of Kotlin Cookbook in an actual bookstore
It’s cool to see my book in my local Barnes & Noble in Glastonbury, CT, but let’s be clear about this. The book is there because back in December after it was published I told the manager I was a local author and asked them to carry it. They ordered it, which is nice, but if history is any guide those books will sit on that shelf for weeks until they’re eventually sent back to be pulped. After all, I don’t know anybody who buys technical books at B&N. I rarely do myself, though sometimes I make an exception. Most developers, if they buy print books at all, it’s usually direct from the publisher (like Manning or Pragmatic Programmers) or from Amazon (like my books there) at a discount.
Still, it’s always a hoot to see your book in a real, live bookstore, so it’s worth asking. I have to admit, however, I’ve been down this path before. For example, here is a picture from the same store back in September of 2017:
That’s shortly after my book Modern Java Recipes came out, and I convinced the store to carry not only that book, but my earlier Making Java Groovy book as well.
(Not that anyone is wondering, but my book Gradle Recipes for Android was published by O’Reilly in conjunction with Gradle, Inc., who gives it away for free.)
Anyway, back in 2017 B&N ordered both my earlier books and put them on the main Information Desk. After several weeks of being ignored, they eventually moved them to the Local Authors display:
Nothing stubbornly persisted in happening, so they migrated back to the Computer section, and eventually after yet even more time went by the books were sent back to the publishers.
Speaking of Making Java Groovy, that book came out in 2013. That was my first book, and my first push to get my local store to carry it. Here’s a picture from the same Barnes & Noble from March, 2014:
Again, thanks. Now you can send it back.
That time, however, I at least got a decent story out of it. While I was writing the book, I noticed that the same bookstore had one shelf labeled “Computer” and three (!) labeled “Teen Paranormal Romance”, two of which are shown in the picture below.
I therefore decided that for my book to sell, what it needed was: more vampires. I therefore wrote an application in Groovy that accessed the data at the Rotten Tomatoes site via their programmable API to download information about vampire movies. I then created the following picture:
The blue highlighting really makes the outfit, don’t you think?
I wrote a whole section of the book describing how to use Groovy to download data from Rotten Tomatoes, store in it a MongoDB database, and then serve it up using the Groovy-based micro-service framework Ratpack. Here’s a relevant page from the book:
Footnote 17 contains both a Blazing Saddles reference and my sense of humor
After a copy of my book lived in B&N in the Computer section for several months, I decided to take the bold step of moving it to the Paranormal Romance section myself.
My book, surrounded by paranormal activity
Later, after another trip, I decided that more was needed. I prepared the following post-it note:
My intention was to put this on the cover of the book, so anyone shopping for vampire books would know that my book fit into the genre. Unfortunately, when I got there, the book was gone!
I thought maybe someone had actually bought it, but when I asked at the information desk about it, no such luck. Somebody presumably just moved it and nobody could find it any more (which incidentally is the downside of print over ebooks, but that’s another story). Eventually those got sent back as well.
So my luck selling physical books through physical book stores is not great. I got a decent presentation out of it (entitled, naturally enough, Groovy Vampires: Groovy, REST, NoSQL, and Bad Marketing) that I gave at a couple of conferences and user groups, but that’s about it.
So now we try again. I tweeted about it:
We’ll see what happens. At the very least, I got a story for the newsletter out of it.
Android in Java and Kotlin
Last week I talked about the dilemma I faced this week with Android. Until very recently, I always taught my Basic Android class in Java, but that’s not what I want to recommend anymore. It still works, but last year Google declared Kotlin First for any new Android-related development, so that’s really what I want to use. Besides, that’s a big reason I got involved with Kotlin in the first place. But while Kotlin usage is definitely growing, it’s still tiny compared to Java, and I couldn’t expect my students to already know it.
The other problem, also highlighted in that same blog post, is that Google would prefer Android development to use their set of components known as Android Jetpack, and I haven’t done much of that yet.
My compromise was to use both Java and Kotlin. I wrote the basic stuff in Java, then did it again in Kotlin and answered questions about it. Toward the end of the second day, I showed a bit about Kotlin coroutines (the Kotlin concurrency model, also very popular among developers) and a bit about the lifecycle components, but not too much.
Nobody complained, but it still felt rushed and overly complicated. I’m still trying to decide if that’s me or just the state of Android development in general. I’ll keep working on it. Next time will be better.
When is deprecated really not?
My other course this week was the first time I taught Spring MVC on the Safari platform, and here I fell into a trap. I’ve been using the MVC (Model-View-Controller) part of Spring for many years, but part of it includes a class for accessing RESTful web services called the RestTemplate. I really like that class, because it’s simple and intuitive. As I mentioned in last week’s newsletter, that class is now all but deprecated in favor of a new class called WebClient. I wanted to use the newer class to do all my testing.
The problem is that I the class was based around the web module, but the WebClient class is in a different part of Spring, known as the webflux (or reactive) module. It turns out you can’t do everything I needed to do in my app with just the webflux module. In the past I just shrugged and tried to use both the web and webflux modules together, but that recently led to other stability problems.
So for this course I made two separate applications, one just using the web module and one just using the webflux module. The two apps had a lot of overlap between them, and my justification for doing that was that I needed the WebClient class and that was the only way to get it.
As it happens, I’m now pretty sure that while the RestTemplate class is on its way to being deprecated, the class I really needed, known as TestRestTemplate, is still fine. Huh. That meant that I could have done everything in just the web module and avoided all the webflux related issues and questions.
Long story short (I know, too late), after the class I revised my sample web app to contain everything I need, so next time I don’t have to include the webflux module at all. I just wish I hadn’t said it was necessary in the first place. I did use it, but next time everything will be simpler. Sigh. Live and learn, I guess.
Imagine deprecating class X but not TestX. Maybe I had a right to be confused, but I wish I’d realized the issue before my class started.
Groovin’, on a Friday afternoon…
We finally, at long last, managed to do another episode of the Groovy Podcast. Here is the tweet about it, which includes the YouTube link, the PodBean link (for audio only), the link to the show notes, and our Twitter handles:
New episode of the Groovy Podcast, S04E04! YouTube:
Podcast links:
Your hosts:
It’s been far too long since we did a podcast, so that was both fun to do and a relief that we finally took care of it.
Finally, I mentioned at the top of this newsletter that I’m getting involved in converting several of the recipes from my Kotlin Cookbook into the katacoda system. But this newsletter has already gone on far too long, so I think I’ll save that for the future. Suffice it to say that, like everything else I do, it’s more work than I anticipated, but hopefully it’ll be useful for future students.
Last week:
Basic Android online at Safari.
Spring MVC online at Safari.
Recorded episode 78 (S04E04) of the Groovy Podcast.
Next week:
Travel to the wilds of Wisconsin for a pair of Spring and Spring Boot private live training classes.
You know what would be nice? Getting back to my Managing Your Manager book.
Also I have to work on those katacoda things, whatever the heck they are.