Invokable controllers

For several years I have been a fan of invokable classes, typically to act as action classes for forms and to create jobs for queues etc.

With regards to forms, this works well. The validation and creation code is all contained in one class keeping code out of the controller. If all you need is validation and a little logic before saving/updating, this model works well. The model breaks down when the complexity goes up.

On a recent project, I needed to validate the request, convert the data, generate lots of additional values related to fluid flow and validate again. Only after I have calculated the viability of the submitted data, do I save the request.

My action classes have simple names – createGame, saveUser, – you get the idea. From reading the name of the action, you know what it does and when you look inside, you have an idea about what you will see. This doesn’t work when there are five or six steps that must happen before the “quote” is created.

Invokable controllers to the rescue – I get all benefits of invokable action classes without the negative of a giant action class which is doing more than its name suggests.

I rarely use invokable controllers but when I do, they are a life saver.

Supporting multiple measurement units

I’m working on a freelance project in which there are multiple measurement units. For example, 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!

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

To try and keep it simple, I have ingress objects which take all values and convert them to a ‘known’ unit of measurement for each type. I can then process all my calculations and not need to be concerned with converting anything whilst I’m calculating. When done, I have egress objects which convert everything back to the required unit and format.

I’m also storing everything in the original format, and I’ve tended to find over the years that this is better than converting and then storing. Customers don’t tend to like it when a value of three returns as 2.99997 next time they look at the request.

I’m only a little way into the project but so far, having a single interface to deal with is making much easier as I only need to care about the units for a value at the time it enters the ‘service’ and the moment it exits the ‘service’ and is about to be presented on screen.

Hopefully, all goes well, only time will tell.

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.

1000km

I started running at forty-two and on telling my wife about my new soon-to-be obsession, she laughed at me! Seemingly, the idea of me running was funny but my wife should have known better.

The first two years did not go well. I ran around 200km each year, 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 a change of mindset and I decided to become a runner. (In my head anyway, 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.

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 my mileage of the last couple of years.

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

As of today, I’ve run 1067km so I’m well on target to triple the goal I set for myself at the start of year. I’ve taken 6 minutes of 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 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.

Budget Pro is in development

I started playing around with Budget Pro at the end of October, initially the landing page and ideas for the design. I’m still very much in the preliminary stages but I don’t think development will take too long as I have the experience of Budget behind me.
Originally, my intent was to take a copy of the Budget code and build all the new features on top and although possible, I’ve realised that long term this just isn’t going to work too well.

Budget is capable but there are two core features which should really be accounted for up front and not tacked on to a working design. Adding support for sharing and multiple budgets means I need to create some sort of “Budget Manager” that knows who owns a Budget and what controls each user has. Additionally, I need a way of surfacing a summary from each Budget rather than just visually as per the free version of Budget.

I’m not going to throw away the Budget code and start again, that would be stupid. The tested Budget service code works well and will just need the odd tweak here and there, it is more about how the service is wrapped and returns data and lessons I’ve learned during the development of Budget.

Budget and Budget Pro are both going to be supported for the foreseeable future, but they are their own products. Budget will get new features and even borrow features from Budget Pro, but it will not become Budget Pro.

Budget beta begins

I have tagged v1.00.0 of Budget, it has now entered the beta period.

The beta period will last for two months and this is a real beta; the product is feature complete. We aren’t adding any new features over the next two months, it is for bug fixes and UI/UX changes based on feedback.

For the next two months I have a freelance project so my days are going to dedicated to that and I’ll work on beta feedback during the evenings and weekends.