Beavis and the Mail Merge

Beavis was fixing a bug where the header in a mail merge didn’t display the correct label. Each country has a different name for their Identification numbers. The data was correct, but the label always showed the English name.

He comes up with a fix where he checks if the region is Scotland or Wales, otherwise he returns the English label. What about Ireland? The bug still remains. What about other countries we support in the future? This will require a further change to this code.

He takes the text from a resource file which is fine. He wrote some unit tests which covered his few scenarios. However, he was comparing the returned value to the text from the resource file. This means if someone accidentally changes the text in the resource file, then runs the tests; it will still pass. The tests should have been written with hard-coded text so isn’t so coupled to the actual implementation.

When it was submitted to review, the Lead Developer comments that it doesn’t fix all scenarios. He also made a brilliant point about another aspect of Beavis’ code. He was taking the customer’s information from the currently selected customer. This is mail merge. Mail merges are often done in batches. There isn’t just one selected customer, but a list of them. This could take the wrong person’s data.

A few days later, Beavis finally came up with the expected solution. The next day, it still isn’t checked in, and his update was along the lines of “I’m updating my branch”, which should only take a minute, not the entire day. I checked the history of the Bug. It has taken him 2 weeks, when I reckon I would have completed it in a day.

Later on, I overhear a Lead Developer express his concern to a manager that Beavis had been really slow and hadn’t showed any thought or care about his work.

It’s nice that it has been flagged as an issue.

Mini Musing #5: It Doesn’t Compile

I was having a nosey at the latest Pull Requests and there was one from Colin. Usually, there’s a good few mistakes in his code. The Lead Developer comments:

“Does this even compile”

To which Colin responds:

“No, lol”

He never learns. How many times does he have to make these mistakes to realise that: if you make a change, then test your changes? When there are unit tests, it’s a simple as clicking a button, then waiting a few seconds.

Joined up working

I think it’s best if you have teams that are in the same location since meetings are easier to arrange and have fluid communication.

If you are in the same office, you can have ad-hoc face-to-face communication. You can all go into a meeting room and don’t need any conference-call equipment which can have all kinds of problems; disconnecting, low audio quality. Same time-zones means there are more hour slots available to arrange meetings in.

I’ve heard people imply that teams end up being distributed just so that the other offices feel like they “feel part of it”/feel integrated into the company. Yet giving them a dedicated project they are responsible for would probably achieve that better; they will have more responsibility/autonomy. Adding members from the main development office makes it feel like they are been supervised.

Many times, you rely on a third party of some kind (by third party, this could be another team within the company or a different company). Maybe the third party collects the data and you just retrieve it via an API. You don’t really care about how the data got there, just that you can use it and it works accurately. Your team that wrote the user interface feel like they have achieved something. The team that collated the data and provided the API feel like they have achieved something. The teams may only need to communicate for a minor part of it. The teams need to know the overall aim, and what parameters they need for the API. My point here is that you can have two different teams with some minor collaboration, but both feel like they have contributed massively to the overall goal of the project.

I think adding a remote worker for the hell of it is just inefficient. Unless they are exceptional and can’t be replaced by the talent you have locally, then its just adding in unnecessary inefficiencies and causing unnecessary bottlenecks (have to delay meetings due to time-zones), have to wait until the next working day to get a response, different countries having different National Holidays.

2020 Vision

Recently, we have had a few meetings where Senior Management have given updates of the plans for the year. I always come out of these meetings non-the-wiser since they just talk buzzwords and marketing jargon. To me, it just translates to “we are doing work to improve our products”, but yet they ramble on for 45-60 mins.

I wrote down some words and phrases from the meeting. So here are the plans/vision/roadmap for 2020:

  1. interoperability
  2. driving efficiencies
  3. minimise the pipeline
  4. bringing on-stream
  5. embedding the modules
  6. mobility strategy
  7. rolling enhancement program
  8. put us in a strong position as we go through 2020
  9. decoupling the need for multiple products
  10. gain focus
  11. add value and retain customer base
  12. technical debt being addressed
  13. a step forward in innovation
  14. marketplace acceleration
  15. improve discoverability
  16. improve sign-up flows
  17. laying the architecture down
  18. building into propositions
  19. specifically aligned with the digital proposition
  20. product portfolio
  21. leverage across different markets
  22. release the roadmaps imminently

Team Duplicate

Part of my team’s work is basically to create a framework where other apps can be plugged into. So this framework has a menu bar and is responsible for functionality that can be used independently of which app you are using. A good example of that would be Chat functionality.

So a part of this project is to create a “proof of concept” (POC); have the “shell” with some sample apps. When other teams make an app, then it can be tested within this POC.

Recently, another team has been putting together a POC which demonstrates how applications can be integrated into the shell. Have I just repeated what I wrote above? Oh, yeah. They are duplicating our work.

Who came up with this idea? Who planned this work? What is the point of it?

I asked one of the developers what the point of his work was, and he replied “you will have to ask the team leader”. I’m thinking “hang on, you agreed to work with them and you don’t even know what the point is?”

Our POC has our shell with a couple of other apps that other teams have produced. The duplicate POC has our shell with some apps that their team has cobbled together. I just don’t understand this at all, not only is it inferior because it’s not using other team’s work; a few developers have just wasted weeks writing apps that no one will ever use. It will just be discarded at some point. Or that’s what I initially thought, but I did hear the manager who is in charge of this say something like “this will be the POC that teams will refer to going forward”.

The other week, one of Team Duplicate’s members, Liam joined our stand up. When we mentioned some upcoming work, he volunteered to speak to another team we were waiting on, which seemed very generous of him.

A few days later, I went to pick up this work item from our Backlog. So I asked Liam if he had any information about it. He then gave me a weird reply along the lines of “I don’t think we need you unfortunately”. I was thinking “wtf, you are firing me with no authority!?”.

I then found out a member of his team was already working on it and he thought I was asking if I could assist with their work. I told him it is on our Backlog and he was telling me it was on his team’s Backlog too.

Obviously, we are duplicating work. This illustrates it. We need the functionality for our POC, they need it for their Duplicate POC.

In the end I picked up a different requirement. I mentioned this to a developer in Team Duplicate and he said “oh yeah, I need to implement that too”. I was like “you are joking, right?”. He says he wasn’t. So I said “I’ll race you then”.

I implemented it first.

Why is my build failing?

A Senior Developer asked for help on Slack. His build failed, so he triggered it again and it failed with the same error. He had hoped it was just a random failure.

I pointed out the reason it had failed is because there was a failing unit test. His code change was a one line change. He had changed a boolean value from false to true, but hadn’t updated the unit test.

After I pointed it out, he then deleted his post for help. Destroyed.

GitHub Actions

Probably a common thing I’ll discuss on this blog is people using technology just because it’s apparently cool. In a way, it is similar to when people write programs using languages they know, rather than using an appropriate language for the task. It’s like the mentality is “I’ve learned this thing, so I’m gonna use it!”

Teams have been using AWS Code Build to build their applications. Then one team decides to be different and try some new technology; GitHub actions https://github.com/features/actions. When their source code is on GitHub, it does make sense to use Build tools there, but at the same time, every other team is using AWS, so why not be consistent? To be fair, I guess a good reason to use it is that you get 2,000 free minutes a month, so I guess it is cheaper for one team to use it.

Now, there’s a couple of things I want to mention here.

A) This team that uses GitHub Actions has many people that I mentioned in the Anti-Microsoft blog (https://strangercodingtings.home.blog/2019/10/29/nerd-elitists-1-anti-microsoft/). Now, the funny thing is that Microsoft acquired GitHub back in June 2018 (https://techcrunch.com/2018/06/04/microsoft-has-acquired-github-for-7-5b-in-microsoft-stock/), and therefore, their servers are running on Microsoft’s Azure platform. I do wonder if those guys are aware of this.

“GitHub hosts Linux and Windows runners on Standard_DS2_v2 virtual machines in Microsoft Azure with the GitHub Actions runner application installed.”

https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners#about-github-hosted-runners

B) In my team, we have 4 repositories, and 3 were set up to use AWS Code Build. I submitted a Pull Request to configure the fourth. I get a comment on my Pull Request saying “changes are OK, but I recommend using GitHub Actions instead”. No justification for it, he just thinks it’s cool, so wants me to undo the few hours work. I can understand if there was a strong advantage for using GitHub Actions over Code Build, and if there is, I would want all 4 repositories converting, not just 1. It just adds to the confusion, and adds to the things you need to learn and maintain.

William

I’m gonna create a new character called William because I have a good feeling he will be a good source of stories, so don’t want to group his stories with Colin.

There was a time I was looking through the recent changes to our software and I saw someone had added some additional error logging. When people have done this in the past, its because there is a bug they cannot recreate, so they need to add additional logging code to gather extra information in order to diagnose the issue.

Anyway, I look at the code and realise that what they were logging wouldn’t be helpful at all. I asked the developer what he hoped to achieve and he said “William told me to do it.” So I was like “If William asked you to jump off a cliff would you do it?“. He replied “But William is a Senior“. I was like “so what? you need to consider things for yourself“.

Recently, William has got involved in our project and has been trying to help decide how to approach our architecture.

We were discussing how users could be updated with real-time changes to data. William stated we couldn’t use SignalR. I asked why and he gave me a shocked look as if it was obvious. “It doesn’t work with web browsers” he said. Weird, I thought, because a partner product uses SignalR for their website.

SignalR supports “server push” functionality, in which server code can call out to client code in the browser using Remote Procedure Calls (RPC), rather than the request-response model common on the web today.

https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/introduction-to-signalr

I was looking into a solution involving Web Sockets and he came over and told me it has been ruled out because it is limited to 1 million connections. I was like “1 million connections? How many do we need?“. He was like “we need to think bigger than that, Websockets isn’t scalable“.

I asked around to get an idea of our current userbase. Turns out we have ~180,000 users, but around half will be active at any one time. So even if we did scale it up, 1 million is more than enough. I was speaking to one of the Architects and he reckoned that the 1 milllion limit can be surpassed with certain implementations.

Anyway, it got me thinking that maybe you shouldn’t always assume people know what they are talking about. William states things with such confidence that it sounds like he knows what he is doing, but really; it’s just the first idea that popped into his head.

“As a junior developer, hearing others say “I don’t know” is extremely reassuring and erases the common misconception that experienced developers know the answer to every question, and have a solution in the back of their mind for every type of problem. Admitting you don’t know something is nothing to be embarrassed of — instead, it’s a new learning opportunity for everyone involved! It may even lead to another occasion to pair programming or debug a problem together”

https://dev.to/httpspauline/5-ways-to-create-a-junior-developer-friendly-culture-3n4

So if William admitted that he needed to do some research, we could have investigated various messaging technologies.

Without me questioning his statements, we could have rejected two perfectly viable options.

Website Bundle Size

I was looking through our application and removing redundant code. I was checking the size of our application and wondered if I could reduce the size. A smaller download size will give the user a better user experience.

How long will you wait for a website to load before you give up and go somewhere else? Ten seconds? Twenty seconds? Apparently, nearly half of us won’t wait even three seconds.

https://www.bbc.co.uk/news/business-37100091

In my research, I found this blog https://www.freecodecamp.org/news/3-easy-ways-to-boost-your-web-application-performance/ which mentions a few areas to look at; reducing image sizes, code-splitting/lazy loading, and reducing the bundle size.

For the third point, it gives an example of a Javascript date library called “moment” which is something my team was using. When I looked at our bundle stats, Moment was contributing to 30% of the size of our app! We only used it as part of a Date picker control which we use once. The blog recommended a website called Bundlephobia e.g. https://bundlephobia.com/result?p=moment@2.24.0 which shows you the size, and recommends some alternative libraries. Moment is 231.7kB and 65.9kb (compressed) whereas “daysjs” is only 6.5kB and 2.76 compressed. If you look at their time stats, the site reckons it will take around 1 second longer to use Moment rather than DayJS.

According to research from digital performance measurement firm Dynatrace, just a half second difference in page load times can make a 10% difference in sales for an online retailer.

https://www.bbc.co.uk/news/business-37100091

Git Hub user martinheidegger logged this very issue back in Aug 2016 https://github.com/moment/moment/issues/3376

It looks like development/maintenance has slowed down this year, but I’m surprised that the Moment library hasn’t been abandoned completely. Loads of people have highlighted the size is a problem, yet no one has actually sorted the issue out after all these years.

When the research highlights how important fast speeds are to users, then you would think developers would put more important on performance.

Untested illogical code

A Junior Developer sent a Code Review for some C# code. There was a bug that if a user didn’t have permission for a particular record, the code would try and look for the record and couldn’t find it, then it would then crash.

Not only was the “fix” a classic case of merely hiding the bug, rather than addressing the fact of why the code was trying to find the record in the first place – but the fix produced couldn’t possibly work. The Junior Developer had written some code like this:

public boolean HasPermissionToAccess(int recordId)
{
 try
 {
    records.singleOrDefault(record => record.id == recordId);
    return true;
 }
 catch(InvalidOperationException)
 {
    return false;
 }
}

Another developer had beat me to the review, but he nicely asked questions to hint that this can’t possibly do anything beneficial; along the lines of “can you tell me where the exception is thrown?” and “can you tell explain why these return values work?”. I would have just said “you cannot possibly have tested this”.

The thing is, the Junior then gave an answer like “the singleOrDefault line will return null if the user doesn’t have permission”.

Yes that is correct Junior, but you ain’t doing anything with the return value. You are returning “true” regardless of what happens. i.e the user “HasPermissionToAccess”. Surely it should return “false”? Also how can the catch block ever execute? singleOrDefault will never throw that exception. Since his new method always returns true, then the calling code will still crash in the exact same place it did before.

I don’t understand how you can write code with the aim of fixing a crash, but it doesn’t even fix the crash. On a positive note, I guess it didn’t introduce any other issue, other than being completely redundant.