Using a Local Record for Readability

Sometimes there is something we really want to put in our cert book that doesn’t fit. You can only have so many case studies/real world scenarios after all. I rescued this from the trash heap and made this blog post./

Suppose we want to count the number of names that have both a first and last name beginning with E. We want to call the method as:

var names = List.of("Sarah Smith", "Eve Edwards");
System.out.println(local.countNamesStartingWithEs(names));

We can read this with streams:

public long countNamesStartingWithEs(List<String> names) {
   return names.stream()
      .map(t -> t.split(" "))
      .filter(a -> a[0].startsWith("E"))
      .filter(a -> a[1].startsWith("E"))
      .count();
}

The code works. However, it has array positions sprinkled throughout. This requires you to keep remembering the format. We can refactor using a local record:

public long countNamesStartingWithEsWithRecords(List<String> names) {
   record Name(String first, String last) {}

   return names.stream()
      .map(t -> t.split(" "))
      .map(t -> new Name(t[0], t[1]))
      .filter(n -> n.first().startsWith("E"))
      .filter(n -> n.last().startsWith("E"))
      .count();
    }

The record lets us give the fields names so we can reference them as n.first() and n.last(). The only place that has to know about the order is the call record constructor. For such a simple example, the approaches are similar. For longer and more complex pipelines, the local record approach can make the code easier to read.

Jeanne’s 1Z0-829 experience

I passed the 1Z0-829 today. The exam page still says “coming soon” and Scott didn’t see the 829 in the list of choices when he looked last night. I think the exam “wasn’t quite ready” and they pulled it back. (or accidentally released it too early). I guess I got to take it because I was registered already. I saw 5-6 errata on the exam which I have reported to Oracle.

COVID logistics

When I took the 819, I was asked to remove my mask twice – once for an ID check and once for a photo. This time, those steps were combined, so I only had to remove my mask once.

I hadn’t been to this test center before. It was walking distance and well set up. I was a good distance from any other test takers. The only problem I had was that I was right next to the radiator. It would have been hot even without a mask on. With a mask, I was sweating.

Other logistics

I was given a marker and since sheet to write on. I was not given an eraser. I asked for a second sheet and was given it though. (I write a lot.) The man in front of me asked for a second marker because it had run out once. They were flexible.

Some time ago, you could right click answers to cross them out of consideration. This feature is not yet back.

Time management

My first pass of the exam took 65 minutes. I then spent a good while examining and memorizing the questions that I believe to have errata. I didn’t get a chance to go through and sanity check my answers because I was tracking errata. If I wasn’t a cert book author, I’d have focused on review and gotten a higher score.

Getting the score

I got my score right when I submitted. (68%). I didn’t get a printout. But I didn’t need one since I had seen the score. My details were available on certview as soon as I got home as well.

You might notice the passing score is also 68%. Why so low you ask? A few reasons

  • Some of the errata resulted in having to guess at the answer. For example a question saying to pick two correct answers had three correct answers. So i had to guess what the exam creators meant. (I have reported all of these to Oracle, there were a bunch)
  • I didn’t check my answers because I was dealing with the above.
  • A few questions were things I didn’t expect to be in scope. (They will be covered in the book.) This is one of the disadvantages of being a cert book author – you have to take the exam without a study guide.)

I felt way more confident about this exam than I did the 819 though. I like the question distribution better and I didn’t have a COVID lockdown cloud hanging over me.

Question Distribution

When taking an exam, you have to agree not to share what was on it. So no details about what was covered. Sharing the distribution of questions by objective is fair game though!

Note that this is approximate because of relying on memory. And also because some questions spanned objectives

Objective# Questions
Handing date, time, text, numeric and boolean valuesLots
Controlling Program FlowLots
Utilizing Java Object-Oriented ApproachLots
Handling Exceptions3-5
Working with Arrays and Collections4-6
Working with Streams and Lambda expressions4-6
Package and deploy Java code and use the Java Platform Module System4
Manage concurrent code execution4
Use Java I/O API4
Access databases using JDBC2
Implement Localization2

An important disclaimer about randomness

With only 50 questions, randomness is a bigger factor. This means you could easily not see questions on a topic. Or get more than someone else on another topic. Be careful as you read the experiences of people who have taken the exam. Just because they didn’t get a question on X doesn’t mean that you won’t! So you don’t get to skip studying topics.

Presenting vs interacting online

Today I ‘presented” at the NYC Scrum User Group on “Remote Agile Games“. I’ve been avoiding presenting remotely. I did do a panel. Today wasn’t bad. I think the key reasons were

  • It wasn’t a lecture
  • No slides (or code). Just me and the audience.
  • Enough people were on video
  • Part of it was a game (so I wasn’t speaking)
  • The audience participated, shared experiences, etc

All this made it feel like a conversation. Which isn’t draining the way an online presentation is.