Supporting multiple measurement units

Chalk sketch of two puzzles with words ingress and egress

I’m working on a freelance project in which I need to support multiple measurement units. In the App customers can provide their required flow rate in litres per second, litres per minute, litres per hour, cubic meters per hour, gallons a minute or imperial gallons per minute.

Warning: This gets really complicated, fast!

Imperial and Metric

You might have noticed we need to support imperial and metric measurement units. Well, that means we need to support mm, meters, degrees Celsius and the relevant inferior imperial versions some people still use. You know who you are.

Ingress and Egress

To keep business code simple, I have ingress object. These ingress objects take all the given values and convert them to a ‘known’ unit of measurement for each type. I then process all my calculations and do not need to be concerned with converting anything whilst I’m calculating. Once everything is calculated I pass everything into the egress objects, these convert all the data to the original unit and format.

Customer data is sacred

I store everything in the given format. I’ve tended to find over that it is better to store the original customer data and convert behind the scenes. Customers do not like it when their entered values of three gets returned as the 2.99997 the next time it appears on the screen.

I’m only a little way into the project but so far this is working well. Having a single interface to deal with is making my business code much simpler. I only need to care about the units for a value at the start and the end.

Hopefully, all goes well, only time will tell.

This project is the gift that keeps on giving, here is another post on integrating with Business Central.

Blog posts on freelance projects are deliberately a little vague as I can’t really divulge too much, I can talk about general stuff but obviously I’m never going to mention specifics.

I Ran 1000km in 2022

Running track with 1000 written on to signify the fact I run 1000km in 2022

I started running at forty-two and on telling my wife about my new soon-to-be obsession, she laughed at me! The idea of me running was funny but my wife should have known better. As per the title, at the time of this post I have run 1000km this year.

The beginning

The first two years did not go well. I ran around 200km in 2020 and the same again in 2021. I wasn’t very consistent and even though I got a little faster and hit some self-set milestones, I didn’t feel like a runner.

This year came with a change of mindset, I decided to become a runner. This was a me problem, everyone that runs is a runner. I ordered a new watch (Garmin 945 – thank you wife) and decided to start taking things more seriously. I was going to up my mileage and follow all the advice – run easy, build up gradually, warm up, you know the drill.

The new goal

I decided I needed a goal, so I set myself a goal that was challenging and yet seemed achievable. I was aiming to run a total of 400km in 2022, so doubling the mileage of the last two years.

I did not follow all the excellent running advice, none of us do. Slow easy running does help but I’m terrible for wanting to always hit a new personal best.

1000km of running

As of today, I’ve run 1000km, well 1067km. I’m well on target to triple the goal I set for myself at the start of year. I’ve taken 6 minutes off my 5km time, hitting 24 minutes and got my 10km time down to 52 minutes. The impressive part, to me at least, is that neither of those times are race times, they were set during training, and both started off easy. I’ve no idea what my go for broke times are.

I’m forty-six next year and before I get there, I’d like to get my 5km time down to 21 minutes and my 10km time down to sub 48 minutes. Both targets seem achievable and according to my watch I’d be able to hit those times today given perfect race conditions, so we’ll see, I guess.

Next year

Next year I don’t think I will be able to reach the same mileage. I’ve been freelancing this year and am free to run when I choose to as I can do my work any time of day. I’ll be contracting next year so it will be slightly more difficult to fit the runs in.

I’m aiming to enter two ultramarathons next year, both 50km. That’s a new challenge and I’m really looking forward to them. It’ll be a big step up for me as the longest single run I have done so far is 20km.

Early next year I will write a progress post explaining how I got on this year.