Book Report: Java by Comparison

      No Comments on Book Report: Java by Comparison

Java by Comparison
Become a Java Craftsman in 70 Examples
Simon Harrer
Jörg Lenhard
Linus Dietz
The Pragmatic Bookshelf
Raleigh, North Carolina
https://java.by-comparison.com

Welcome to my first book report since my high school days. I’ve chosen to write about the book Java by Comparison primarily because it’s the book I wish that I wrote. There are plenty of excellent books on specific frameworks and libraries, but this book doesn’t concern itself with this. Instead, this book with its multiple topics and 70 examples presents the best general approach to coding in any situation. As an instructor in computer programming, I consider how you code is as important as what you code and this book may be the finest example of instruction in how to code.

The book is presented in nine chapters or comparisons, each of which examines one aspect of the programming process. The first comparisons, entitled Start Cleaning Up, is where I found some of what I refer to as best practices when coding. In the introduction to this chapter the authors wrote:

Writing code that’s easy for humans to read and understand is much harder than writing code that compiles.

This is a sentiment I agree with. Submissions from my students that compile and execute are not a guarantee of a good grade. My students will be graduating and joining teams where code will be shared. My favourite section of this first set of comparisons is Ensure Code Symmetry. This is something I see in my students work where multi line switches or if/else statements deal with conditions that are unrelated to each other.

The second set of comparisons is entitled Level Up Your Code Style. One of my favourite topics here is Favor Java API Over DIY.  Sometimes I feel that programmers, by this I usually mean my students, do not spend enough time reviewing the APIs that Java offers. The result is reinventing the wheel. I tell my students that the APIs were written by programmers far more intelligent than myself and them. I even learned a new API in the Collections library called ‘frequency’ in this chapter.

Use Comments Wisely is the third set of comparisons and possibly my favourite. Its is not enough to have comments but rather to have meaningful comments. In the introduction to these comparisons they write about documentation for a smart TV device:

In the section titled “The Record Button,” all it says is, “Starts the recording.” Anyone could figure that much out just by looking at the red Record button! And what happens if you hit the Power button during recording? It doesn’t say.

They then go on to explain the best practices for comments. I especially like the advice to include examples of usage in the comments.

The fourth set of comparisons, Name Things Right, addresses one of my pet peeves, how identifiers are named. I frequently find myself assisting my students in debugging their code. I’ll see an identifier in their code and ask what this class does. The answer is often that its not a class but an instance of a local variable. The same happens when class names begin with a lower-case character.

The fifth set of comparisons is called Prepare for Things Going Wrong. In the section Expose Cause in Variable it is proposed that custom exceptions can best be used to describe errors specific to the code you have written. Rather than try and pick a Java exception class closest to the problem, you should be creating custom classes that can provide the very specific information a programmer may need to understand what has gone wrong.

The sixth set of comparisons, Assert Things Going Right, discusses the best practices for unit testing. It starts with the excellent advice in the section Structure Tests Into Given-When-Then. This will become part of my lectures on unit testing. There is one recommendation where I disagree with the advice to avoid @Before/@BeforeEach. The authors write that explicitly calling an initializing method is cleaner than using the implicit @Before method. On this point we will agree to disagree.

Design Your Objects is the seventh set of comparisons. Here is an excellent discussion called Avoid Returning Null that demonstrates how using instantiated but empty objects are a better return value for indicating a problem rather than just returning null. As Java evolves through its six-month release cycle, I expect two Java constructs to disappear. These are ‘new’ and ‘null’. Until then this set of comparisons is full of excellent advice.

The eighth set of comparisons, Let Your Data Flow, looks at functional notation. While some programmers think of the functional approach as an alternative to object-oriented programmers, the authors point out that the functional style is best used to enhance OOP. Here I see something I tell my students, use a stream rather than a loop when every element must be visited. It is counter intuitive for some new programmers because so much time is spent explaining loops in their courses. I have even suggested to my students that the ‘for each’ syntax should rarely, if ever, be used. Use a stream instead.

The last set of comparisons, Prepare for the Real World, addresses important issues as a project nears or goes into production. There are fewer code examples here. One topic that I am fond of is called Favor Logging Over Console Output. At my school I teach in the final year where students work on a single project for the entire semester. They arrive ready to use System.out.println whenever they want to investigate a specific method. They are shocked to learn that after I present the topic of logging they are now forbidden to ever use console output again. I threaten to come to their workplace and admonish them if I ever hear they used console output for debugging.

One of the many features of this book that makes it a must read and companion for every programmer is the code examples that illustrate each of the book’s concepts and advice. The book shows the before and after for each topic. Examining these practical examples while reading the book significantly enhances the written text. Taken together, the written text and the code examples, makes this book a must read.

I bought this book as an eBook for retail. It was one of my best investments as both a programmer and an instructor. I plan to make it a required text starting in Fall 2019. Let me end with some lines from the last chapter that describe what the authors expect from you after reading the book.

Now, you’re able to

Spot problematic Java code quickly and know how to improve it.
• Recognize common types of bugs and know how to avoid them.
• Explain why one code is clean and another isn’t.

Ken Fogel, Java Champion, Montreal, Quebec, Canada, 2019-02-13

DawsCon 2019

      3 Comments on DawsCon 2019
The DawsCon Conference Logo

On January 11, 2019 Dawson College held its third annual software conference. Previously called NetBeans Day, this year’s conference was renamed to DawsCon. The final tally of participants was 180. In our first year it was 50 and last year it was 70. The amazing lineup of speakers and, for the first time, sponsorship from a major organization, Deloitte, elevated the conference beyond just a local event.

The Registration Desk

Preparation for this year’s DawsCon began immediately after the 2018 conference. I started tweeting, facebooking, and linkedining to get the word out about the conference. Josh Long, Spring Developer Advocate at Pivotal, Java Champion and resident of San Francisco when he is not travelling, was the first speaker who confirmed for 2019. This came about when he wrote on Twitter how he was looking forward to travelling the world in 2018 promoting Spring. I wrote to him suggesting that we could be his first stop in 2019 and he agreed.

The Deloitte Booth

Pratik Patel, Lead Developer Advocate at IBM and Java Champion living in Atlanta, was next on my list to reach out to. He spoke at the 2018 conference. Not only did he quickly agree to speak but he brought with him Mary Gryglesk, from Chicago, and Billy Korando, from Kansas City, two developer advocates from IBM to speak as well.

Pratik Patel
Mary Gryglesk
Billy Korando

Next, I reached out to Henri Tremblay who had spoken in 2018, a Montreal Java Champion and one of the organizers of the very successful Montreal Java Users Group. Aside from speaking at the event Henri also helped to get the word out for DawsCon to the 2,000+ members of the JUG.

Felix Roberge was another speaker from 2018 and who is now the Chief Technology Officer at D-Teck. I reached out to him and he was more than happy to join us in 2019.

Funny thing about both Henri and Felix. Rather than meeting them at some event in Montreal I first met both in San Francisco at Java One. In Henri’s case I sat next to him on a return flight and then discovered that he was in pictures I took at a Google event at Java One. I met Felix while walking back from the appreciation event at Java One when I heard some people speaking French with a Quebec accent.

Venkat Subramaniam

Venkat Subramaniam, President, Agile Developer, Inc., Java Champion and JavaOne Rockstar, is one of the most sought-after speakers in the world. For the 2018 conference Henri learned that he was going to be close by speaking on the east coast of the US. For that conference he was only going to be available for the Thursday and not the Friday the conference was planned for. Due to the lean conference management structure, just me, we moved the conference to the Thursday so he could speak. This year he squeezed us in between Oslo, Boston, Denver and then back to Oslo. We fit in between Boston and Denver.

Simon Martinelii

Simon Martinelii, of 72 Services in Switzerland, saw my numerous posts about DawsCon and offered to speak. Simon is an example one of the coolest aspects of the software development profession and that is the desire to share what we know. Simon is involved with several JSRs (Java Specification Requests) that drives the evolution of Java. Simon came to Montreal with his wife and my wife and I had the opportunity to spend a little time with them and do a little sightseeing.

Hugh McKee

Initially we were expecting Markus Eisele, another Java Champion, from Lightbend to speak. Unfortunately, due to scheduling issues, he needed to be in Hawaii for LavaCon, he was unable to attend. In his place he arranged to have Hugh McKee, Developer Advocate at Lightbend coming to us from Florida, speak.

Sean Sullivan

Sean Sullivan, a Principal Software Engineer at the Hudson’s Bay Company living in Oregon, was another developer who reached out to the conference to speak. He was already planning to attend and offered up a topic that I felt would interest our audience. You can access his slide deck at: https://speakerdeck.com/sullis/aws-sdk-for-java-version-2-dot-0-dawscon-2019

Hrishikesh Kanabar,Thomas Winter, Brett Leighton, Kevin Huang

Our final four speakers, Hrishikesh Kanabar, Thomas Winter, Brett Leighton, and Kevin Huang, all came from our first ever sponsor Deloitte here in Montreal. Deloitte is actively growing their software services and these four are part of this growing team.

In May I attended an event at Deloitte to encourage us, teachers from Montreal area colleges and universities. to encourage our students to consider working for them. At the last session of the day we were asked what Deloitte could do for us to encourage our students to seek employment with them. I said, semi-seriously, that they could sponsor DawsCon. About two weeks later I was contacted to say that the Deloitte partners had discussed my request and that they will sponsor the conference.

In mid November I was approached by Plusgrade, a software development company here is Montreal, and asked if they could have a booth at the event. Like Deloitte they looked upon DawsCon as a recruiting opportunity. Now we had two sponsors.

Josh Long

If you are someone reading this who might be interested in sponsoring next year, then contact me at kfogel@dawsoncollege.qc.ca. There is just 11 ½ months to next year’s DawsCon.

Plusgrade and their delightful pizza.

The real first sponsor of DawsCon is Dawson College. With the support of Diane Gauvin, the Academic Dean, the space for the conference is made available to us at no cost. She made her staff available to assist me in dealing with the bureaucratic tasks necessary to run a conference. Refreshment costs in the first two years were covered by the College while this year’s sponsorship from Deloitte and Plusgrade should cover that expense. This year the college’s public relations department, under the direction of Donna Varrica, arranged to have a logo designed for us and helped us get the message out to the college community. The college’s web group managed our web site and when changes or additions were necessary, they were carried out quickly. Thank you to everyone at Dawson for your help.

Its a near full house!

One of the important aspects of DawsCon is to allow Computer Science Technology, the program at Dawson College that I teach in, to reach out to the software development community here in Montreal. We have an internship in the final semester of our three-year program and our internship coordinator made several important contacts at the conference.

Some of our student volunteers.

In the end the conference went off without a hitch. We held a keynote at the start of the day and one at the end. Between the keynotes we had two sessions running each hour. The only tiny issue was video adapters. While I have adaptors for mini and maxi display ports, this year’s crop of laptops wanted a USB-C adaptor while all our projectors used VGA connectors. Luckily the speakers from IBM came equipped with all the necessary adaptors. I do remember seeing at one session a three-adaptor chain to get a laptop’s output to VGA. By the end of the day my step counter read 22,320 steps.

Two of our faculty volunteers, Gordon Garmaise and Josiane Gamgo j

I’d like to thank my faculty and student volunteers. Without their help the day would not have been successful. I’d like to thank the Plant & Facilities department of the college whose staff set up the rooms we used perfectly. Even when, on Thursday morning, I noticed that the cafeteria setup was too much to one side the P & F staff were happy to move the stage and every chair about 3 meters to the left.

The secret to Venkat’s success, he is always working.

I started DawsCon to bring a little of Java One to my students and the Montreal software community. I have been fortunate to attend Java One, now called Code One, every year since 2014 with funding support from Concordia University, where I teach part time, and from Dawson College, my full-time gig. I have spoken at that conference every year that I have attended. Unlike JavaOne/CodeOne and most other conferences, with Dawson College’s support the DawsCon conference remains free to attend.

Venkat, Mary and Henri

Don’t forget, DawsCon returns January 10, 2020. By the time I attended Code One last October I had already found all the speakers and had to put some on the list for 2020. If you are interested in speaking at a conference aimed at students and developers, then let me know.

Conference Surprise

While introducing Venkat I was interrupted by Henri. This was unusual but I thought Henri wanted to plug the Montreal JUG. Instead he announced that I have received the designation of Java Champion. Here is the description of the honour from Oracle that I received later that day:

Henri interrupting me while I was introducing Venkat.

“Like your fellow Java Champions, you have demonstrated a proficiency in all things Java and your significant contribution and activity shows true commitment in sharing your knowledge and experiences with the community.”

Student volunteer Suzan Sharif with Josiane

I also discovered that I had been accepted into the Java Champions program back in December but Henri arranged to have it only announced at DawsCon. My swollen head is slowly shrinking to normal but I remain humbled to part of a group of developers I have been in awe of from when I first started coding and teaching Java.

The Dawson College cafeteria full of eager conference goers.