Friday, May 23, 2025

AI will solve all our problems....?

 Apparently, "AI will solve all our problems!"

Even the ones that we know are being created by using AI now?


I can see two responses:

  1. We hope that will be the case. (By the time we encounter the severe negative consequences, "AI" will have been developed to deal with those problems.)
  2. We plan and prepare for these known issues and limit or mitigate their consequences before they become a problem. (Hope isn't always the best strategy - when it comes to technology.)



Thursday, May 22, 2025

Improve .NET MAUI's AppThemeBinding?

 The AppThemeBinding in .NET MAUI is great. But wouldn't it be better if it required a lot less text?

<Label Text="default way (verbose)" TextColor="{AppThemeBinding Light={StaticResource Primary},Dark={StaticResource White}}" />  <Label Text="my way (shorter)" TextColor="{lightDark:Primary_White}" />

I'm a massive fan of code that is clear, expressive, and as short as possible without obscuring any important details.

The default syntax in the top AppThemeBinding example above is indicative of what you'd expect from regular XAML use. It does everything you need, the names are clear, and anyone familiar with XAML will not struggle to read it.

But, I look at it and think:

  • That's a lot of text
  • Why the repetition?
  • Why are so many braces needed? (I know why but wish they weren't.)
  • Can't there be a better, simpler way of telling both the compiler/framework and any developer looking at the code in the future what I want to happen?


As you can see from the picture above, I have a better way, and you can see an example of it there.


Of course, I don't have all possible color combinations pre-defined. I used a Source Generator to create what I wanted by including this attribute somewhere in my code.

[AppThemeColorResource(AppColors.Primary, AppColors.White)]

This example also uses my RapidXaml.CodeGen.Maui library to generate constants for the names of the color resources defined in the Resource Dictionary. I could use hard-coded strings for the names, but that risks other possible maintainability issues.


I also have other variants of the attribute, so I can also do things like this:

[AppThemeNamedColor(nameof(Colors.Aqua), nameof(Colors.HotPink))]

[AppThemeHexColor("#FF00FF", "#8B0057", "PinkOrPurple")]

[AppThemeNamedBrush(AppBrushes.SecondaryBrush, AppBrushes.Gray200Brush)]


Each generates a MarkupExtension that can be used in place of an AppThemeBinding and is named based on the names of the provided brushes or a specifically provided name. (As in the AppThemeHexColor example above.)



The above example uses 'lightDark' as the xmlns alias. I tried various naming styles and conventions for the alias and the generated MarkupExtension but currently prefer this best. I think it communicates the maximum amount of helpful information with the least amount of text.

Examples of other things I've experimented with include:
{ifLight:WhiteElseBlack}
{color:PrimayIfLight_PrimaryDarkIfDark}
{if:LightUseFF0000_DarkUseDD3333}
{appThemeBrush:Green_ifLightElse_DarkGreen}

What would you use?


If you see something like the above, you might be tempted to think, "Yes, it's shorter and easier to read, but what's the downside? I bet it's slower."

If you've never measured how long it actually takes to load different XAML content, that is a reasonable assumption.

Previously, I would have thought the same too. However, I recently built a test harness that makes it easy to measure how long it takes to load different XAML files, and the results shocked me.

I created two pages. Each contains 100 Labels (in a VerticalStackLayout). In one page, each label uses the AppThemeBinding as shown above. The other page uses my syntax. 

In a quick test, loading each page multiple times and in a variety of scenarios, the version of the page that used my syntax loaded 25% faster!


So, my version:

  • is shorter
  • is easier to read/understand
  • has exactly the same functionality
  • and is faster!!!


Now, tell me why you wouldn't want to do this?



NOTE: If you're looking to hire someone to help you build apps with .NET MAUI and you appreciate code that is easy to read, understand, and maintain. Get in touch as I'm looking for work.



creating and making words

I was recently confused by someone who was using creating and inventing (& creator and inventor) interchangeably. I found this confusing. There must be a difference, and it may be useful to understand it.

I came up with these definitions for various creativity-related terms. They're not perfect, and there are exceptions, but sharing here as others may find this useful.

Make - To produce something
Create - To make something that has existed before
Invent - To create something that has never been created before
Innovate - To create something by combining existing things or ideas in a new way
Design - To create something for a specific need or purpose

But what about "creativity'?
In my experience, I believe this is mostly used as a shorthand for idea creation. Being creative means coming up with lots of ideas, possibly using invention or innovation, and seeing how they can meet a need or requirement.

Monday, May 12, 2025

When I built six apps in under 4 weeks

While looking for a new job, I've been thinking about how I quantify the work I've done previously, and I remember the time I built six apps in less than four weeks!

6 / 4
We didn't start from scratch, but compared to everything I have as a reference, it was fast work. I miss working on projects where the goal was to ship high-quality products regularly, and they would be used by lots of people.

So, backing up, the project was a port of existing apps that existed for other mobile platforms. The apps were "city guides" for different cities and were based on published pocket guides for those cities. The apps contained interactive maps of each city to enable the exploration of places of interest. It was also possible to create a custom itinerary of places to visit. Not massively complicated, but for a recognised brand that expected the highest quality.
Six apps, one for each of six cities.

Before we started, all the existing data and assets from the existing apps were gathered, a full review of the existing apps was performed (by everyone involved), and the designer from the agency created visual mock-ups for each of the "pages" in the app.

The [book] publisher hired an agency to build the apps, and the agency sub-contracted out the development to me. As a highly recognised agency, who did work I admired, they were one of the few companies I had always wanted to work for/with.

Prior to starting development, we held a meeting with the designer, product manager, agency owner, and myself to go through everything, ensure all requirements and details were known, and that everything was understood.

The plan was to build a single "core app" that could be "white-labelled". By providing different data files and visual assets, each of the six apps could be produced from a single codebase. I'd used a similar technique before when needing to build localised versions of an app for different countries, each with its own unique content and language.


Here's how the work broke down week by week.

Week 1: Build the custom map control. Without this, there would have been no app. It was the centrepiece of the application: unique functionality that differentiated it from other available apps. Yes, the whole first week was spent entirely on building a single control. It was, obviously, a complex control that contained a lot of functionality. All the functionality had to be easily testable too. It wasn't practical to travel to each city (on 3 different continents) to manually test the functionality.

Week 2: Get all the data in a consistent format. The provided data was in multiple formats. Mostly a mix of CSV files and SQLite databases. So, before building the actual mobile apps, I built a console app that would take all the different data sources and produce standardised, consistently formatted data that could be used by each app the same way. The existing apps embedded and used the raw data files, but it meant that they had to handle all the variations in file formats, data formatting, and incomplete data. Having data in a known and consistent format meant the code in the mobile app didn't have to account for as many variations or possible error conditions. It meant less code and less error handling. When updated data files were available, they could be reprocessed by the console app, and the files it produced were tested for consistency and correctness.

Week 3: Build the app. With all the complexities handled in the previous week, this became a case of building pages for the app(s) that displayed and allowed interaction with the data (& map control). I recall there being fewer than twenty pages in the app. Many pages were reused for different scenarios where the same basic structure could show very different data. These were pretty simple pages to display and interact with a fixed set of data. The challenging work in determining how the pages should look and the possible variations in data had all been considered prior to actually building the UI. This was key to building fast and correctly.

Week 4: Test the app. While doing some final tweaks and checks, I checked and retested everything while the agency's dedicated tester also did the same. Some additional automated checks/tests were also added. Across the entire code base, there were over 32000 tests, but many of these were for checking the data's validity, formatting, & consistency for each place of interest.


One particular memory I have was with the person from the agency responsible for testing the apps before release. They couldn't find any problems with any of the apps. However, like many people responsible for testing software, they didn't want to find no problems. They looked into the data that was being used and raised a single bug that some of the latitude and longitude details (of some places of interest) were specified to an unnecessary number of decimal places. A quick update to the data formatting app, the addition of an extra test that no lat/long values had unnecessary precision, and then the regeneration of all the data and the app was ready to ship. Once released, no bugs were reported.


Small apps with little feedback and interaction from the people using them aren't always desirable, but it's good to know (remember) that I can build them with impressive speed.


Friday, May 09, 2025

When process improvements can be more valuable than code changes

While looking for a new job, I've been thinking about how I quantify the work I've done previously. It reminds me of a role I had where I introduced positive changes far beyond the assigned coding tasks.

I was working in a team (of 8) building desktop software that the business sold. It was high-value software for a specific task and industry. The product was more than a decade old (when I joined), and updates were released (approximately) every three months. Updates would add fixes and new features. Some customers also paid for their own custom functionality.

positive graph showing a line going "up and to the right"

I collaborated with the sales team to provide technical planning support for custom work and, as part of the general development team, implemented planned changes for each release.
It wasn't the most mentally taxing work and didn't break new technical ground. But, it did allow me the time to think about the broader picture of what we were doing and how we were doing it.

Here are five things I did in that role that others on the team couldn't or wouldn't have done.

  1. Streamlined work distribution. When I joined, the work to be done for each release would be decided in advance and then individual tasks would be given out to developers one at a time as each task was completed. This way of working had been done for years, but I quickly identified multiple issues. I persuaded the manager to group related tasks (typically by area of the code base) and give them all to a single developer. This change resulted in faster changes, (so more work could be done for each release), fewer bugs, and developers gaining a deeper understanding of the codebase. Because each developer was spending more time in an area of code they got to know it better, could make multiple changes at the same time and avoid conflicts or rework when multiple developers tried to change the same area of code at the same time.
  2. Increased documentation accuracy and quantity. The company used to have a set of Word documents that detailed developer processes and important information. These were hosted in a read-only form on an intranet. The process for changing or adding a document was slow, and so it wasn't done as frequently as would have been beneficial. I migrated the existing system to a wiki-based solution, which led to more documentation being created and it being kept up to date.
  3. Simplified and automated the release process.  Releases were an important time, but they used to be very slow. Originally, a release would require a "release week" where all the developer team were involved in preparing the release or working on projects away from the main codebase. Creating a release build was a slow, manual process that took three days to complete. This would then be manually tested while custom builds were created for customers with unique features. After going through this process once, I saw the issues and began automating it. I reduced it to a 25-minute process that also included all custom builds. This was run multiple times a day as work was committed to the main branch.
  4. Introduced automated testing. I joined a company with a dedicated manual tester and a technical director who refused to accept that coded/automated tests were a good use of anyone's time. When I was tasked with work that involved multiple complex calculations, I knew I couldn't complete the task without creating coded tests. There were too many variables and scenarios for me to remember everything, and even following a manual script would be slow and prone to errors. I created the tests anyway and even identified many previously unknown existing bugs in the calculations. At our next weekly meeting, I admitted what I'd done and showed how having the tests had not only saved me time and improved the quality of the code, but it also made future changes to this part of the code easier and with less risk of introducing unintended side effects. There was initial scepticism from the manual tester who felt threatened, but once they saw how it freed them up to do other work and reduced the bottleneck of manual testing from the development process, everyone got on board and creating coded tests soon became the norm.
  5. Restructured weekly progress meetings. Every Thursday afternoon, the whole team would gather for a meeting. Initially, this was primarily dominated by each developer individually reporting what they had been working on and giving progress feedback to the manager. Most of the progress feedback to the manager was irrelevant to the rest of the team and so it wasn't a good use of time to gather everyone in a room for a series of 1-on-1 conversations. I suggested moving the progress reporting to email which, happened before the meeting. This freed up the meeting to collectively address any concerns and discuss wider issues or areas for improvement. I particularly remember the final meeting I attended on my penultimate day with the company. When I suggested a new process improvement and explained the benefits, another member of the team asked why I cared when I was about to leave. I replied that I wanted the best for the company and the team, even when I wouldn't be there. And, while I was there, I wanted to do everything I could to make it as good a place to work as possible.
The code changes I made could, arguably, have been made by any of the other developers on the team. That's part of the nature of coding. I expect that the increased use of AI/LLMs as part of software development will further reduce the distinction between the code produced by different developers. The distinguishing factor between developers may come down to their ability to do more than produce acceptable code. Being able to understand how the required task fits into the broader picture and identifying areas for improvement is a crucial skill. A knowledge of the wider business and its processes can also be valuable. Not that individual developers should always question every decision and attempt to change business processes, but they should be able to see and understand the broader environment and offer suggestions when appropriate.
I'm looking forward to competing in this developer marketplace.