I had my 20-year class reunion this past weekend. They couldn’t find enough interest in having a larger party, so we had a small gathering at a restaurant with outdoor seating. It was fun, and I was able to remember everyone’s name.

I’m now in the habit of using Field Notes as a way to keep notes as I’ve mentioned here before. I finished up one this week and started up a new one that’s part of their National Parks Series.

I did more work on my schema entropy project this week. I was able to keep working on dereferencing OpenAPI files and keeping track of which schemas referenced which other schemas to build up a graph of the relationships. I’m tracking circular references as well. This has because a tough area to get right as some OpenAPI go wild with the references.

I’m writing all this in Elixir and having lots of fun. The combination of immutable data, functional programming, pattern matching, and the pipe syntax gel with my brain. I’m parsing OpenAPI schemas and have used no “if” statements. It’s all pattern matching.

def parse(%{"type" => "object", "properties" => properties) do
  # Handle object types here
end

# Sometimes people leave off the "type" property
# I add the type and run it back through parse to match
def parse(%{"properties" => _} = schema) do
  schema
  |> Map.put("type", "object")
  |> parse()
end

Since it’s based on patterns, when I run new OpenAPI files through it, I get specific errors that tell me patterns I haven’t supported yet. The example above shows one I found where some schemas left off the type property. Instead of doing an if statement to check for it and clutter up my main function, I catch the pattern, rewrite the schema, then send it back through the parse to get matched correctly.

I miss these features every time I go to another language that doesn’t support them. Of course, my favorite language has some of the best pattern matching support out there.

Lastly, I think I can credit my Rakefile for helping my brain keep up this weeknotes habit. I run a command to start a weeknote, it opens the editor where I write a few minutes, then I run another command to publish it. If I make a mistake after publishing, I fix it then run the command again.

Notes

  • I finished listening to the audiobook True Self False Self by Richard Rohr.
  • I finished reading Keep Moving: Notes on Loss, Creativity, and Change by Maggie Smith.
  • We watched the movie Hot Fuzz. It’s ridiculous and funny.
  • I’m reading a few books at the moment.
    • The Art of Memoir by Mary Karr
    • New One: Painfully True Stories from a Reluctant Dad by Mike Birbiglia
    • I Feel Bad About My Neck by Nora Ephron
  • My youngest kiddo said, “You can’t pick yourself up because your arms are connected to your body.”
  • My oldest kiddo and I worked on writing a program to solve this silly game called “Drive Ya Nuts.” There’s no skill to the game other than the patience to brute force it until you find a solution. There are only seven possible solutions out of 30,240 possible combinations.