Christmas Without Code Dec 20, 2022

This year as we approach Christmas, I’m in a considerably different position than I was at the same time last year. At work, we’ve delivered some massive pieces of work, most notably MyConnect2, the team has increased in size and we’re doing more than ever, faster than ever, and smarter than ever.

Personally, I’ve moved house (again), however, we own this house, and built it ourselves - Well maybe with the help of an actual builder or 2 - So we’re planning on staying here for quite some time. Which is a different feeling, ironically, in all the last rentals I put up decorations, wall-mounted photos, and hung various things even knowing I’d have to tear it all down again. I have yet to do that here, primarily because of the permanency of it all, something about it. Of course, I can change it up as much as I want, but there’s a good chance in my laziness, that it’ll sit there for 20 years.

The really big news, however, is that I became a Dad, not very long ago - and boy has there been a lot to learn. Hence why I’ve had the last 6 weeks off of work. So this Christmas, I’m not writing code, I’m reading children’s books, changing nappies, and not sleeping. I’ll be back at work relatively soon, (too soon for my taste), but it will be interesting to see how the code base has changed in my absence. Has the team kept up with the very high standards I set? What were the shortcuts taken?

On a side-note I’ve recently purchased a subscription to MidJourney - Which has really enhanced the immersive aspect of my Dungeon & Dragons campaign. Being able to quickly whip up landscapes, NPC portraits, and custom items has added a layer of depth to the campaign very quickly. I look forward to seeing what else I can do with this technology that keeps evolving.

Entity Framework: Performance Hack Jun 01, 2022

Today’s one is quick just like the products we’re trying to build. This one might seem super obvious but it’s helpful to keep in mind regardless. When constructing an EF query, .StartsWith() is significantly more performant that .Contains().

So if you’re trying to keep things fast and efficient use StartsWith instead. This does come at the cost functionality and so can’t be used in all cases, but at least for common searches like email address, not having wildcard matching at the start of the query is acceptable if you can get the search done a lot quicker.

In one example at work, we noticed a 16x performance increase by making this one simple change.

Slow Query

    var searchTerm = "Alex";
    var users = DbContext.Users.Where(u => u.Email.Contains(searchTerm)).ToArray();

Fast Query

    var searchTerm = "Alex";
    var users = DbContext.Users.Where(u => u.Email.StartsWith(searchTerm)).ToArray();
Events & Weddings Apr 29, 2022

In what turned out to be most opportune timing, I conducted a demo earlier today moving us towards an Event Driven Architecture utilising Solace as the message broker.

Why was it opportune timing? Because last night I attended a wedding. Which if you’re not aware, is quite a large event.

If we take the sum of our lives as a system we can reduce it down into all of the various events that happened, how we responded, the changes in state because of responses to those events and the eventual evolution of responses into the future (learning).

Now most of the systems that we as developers spend our time, building, fixing, deploying and enhancing are not nearly as complex as the human machine. However when growing to a certain level of complexity as occasionally happens, sometimes you need to sit back, relax with a cup of tea and ponder if all of the technical decisions that have been made to-date have been correct.

There’s a very good chance that they have, however that also doesn’t mean we can’t improve. Which is why we’re getting our feet wet with Event Driven Architecture.

Currently we’re in the situation where we have dozens of services, applications and systems running around, and keeping track of all the data that flows between is getting hard. There is data that flows through 10+ different systems. That depending on configuration for that particular piece, there could be 4-5 systems that are source of truth so keeping everything in sync starts becoming a priority.

That’s where Event Driven Architecture (EDA) comes into play. Instead of having something like this

You end with something more like

Or for something more colourful

We’re only just started to dive into, by so far the technical challenges have been fairly easy to work with and it is now clear that major obstacle is not the development of such a system, but it is instead the design of such a system. We will be spending a good chunk of time over the next few months designing out how things will work, which is something that we’ve probably not really done very well to-date. We’ve mostly built integrations in an ad-hoc manner when needed.

Things to think about become

  • Topic hierarchy
  • What queues, and how many of them
  • Environment differences
  • Versioning
  • Big data updates
  • Prioritisation
  • Error handling
  • Idempotent Events
  • Auditing

I’m currently also in the pre-build phase of an open-source .net wrapper for the Solace .Net SDK to make implementation of Solace in Modern .Net 5/6 applications as easy as it to use Hangfire or Swagger.

Mastodon