Secure Files

At university, the operating system we used was Linux, and although there was a graphical user interface, we were always encouraged to use the command line. For some people, this was very uncomfortable, and often people didn’t really understand the commands they were typing.

Sometimes we were assigned group coursework, so someone took the lead, and then changed the permissions on their folder so that their team could access it.

The thing is, people didn’t understand what they were typing, or cut corners. This meant that some people gave access to EVERYONE to access that folder. Others granted access for EVERYONE to ALL FOLDERS.

I reported this as an issue because someone could then grab people’s code or written reports, change a few lines and submit it. Easy. It could even be a privacy concern if people have personal files saved on the university system. If you were given permissions to modify, you could delete their files.

The IT guys told me that changing permissions was an allowable feature and it is up to each student to grant the correct permissions, so they rejected my concern. 

They could have at least put out a mass email telling people to check in order to alleviate the potential damage.

The good thing was that when I wasn’t sure of what to do on future coursework, I could then check this new source of information for inspiration. 😀

Wingdings

One of my all-time favourite bugs I encountered as a Software Tester was when a printout was written in Wingdings font.

The developer had wanted to utilise the check/tick character ✔ from the font, so they had programmatically changed the font, then inserted the character. However, they didn’t add the code to reset the font back to normal, so the rest of the printout was also in Wingdings.

I do wonder how people manage to introduce such bugs, because surely you will notice it if you have tested it. The only exception is: if all your tests have scenarios where the Windings character is the final character on the printout.

I really thought it was a once-in-a-lifetime bug and I would never see the likes of Wingdings grace our system again. However, I was wrong, it happened recently with a project involving some document functionality enhancements. Luckily in both situations, the Wingdings bug never made it to the live environment since it was easily spotted by our Testers. 

I bet our users would have loved it more than I did (sarcastic, obviously).

Configuration Switches

Recently, we were running into Out Of Memory issues with our software. A developer had identified that a feature which launched an embedded browser was using up quite a bit of memory, and we could move it into a separate process which would have its own memory allocation.

We followed his recommendation, so we moved the browser into a separate process and released this software (which I will denote “V1”). This caused an issue because the dll wasn’t built with the correct settings. We needed a quick fix due to the number of complaints from our users. It would be easy to fix, but due to the Testers stating it would take a few days to test it again, the managers told us to simply revert it and give the users the memory issues again (so this is “V2”).

We then fixed it, but since we had more time, we decided to implement a configuration switch so that if it went wrong, we could just disable it without having to release a new version. I made a small refactoring to get the configuration switch working, but I made a small mistake in the constructor which caused a crash in one of the places where the browser is launched. A Tester had found it late in his testing. I came up with a fix, but then we got called into a meeting to discuss what we needed to do. Unfortunately, my new fix would require a lot of the testing to be redone. The “refactoring” I did was brought up for discussion, and an experienced developer said that my way of doing it wasn’t the way he imagined. All the managers on the call trusted his judgement and felt I had gone a bit overboard, so they insisted I redo it.

So I had another look and couldn’t see how I could possibly do it without refactoring at least slightly. I did the best I could which I’d say was actually ~90% identical, apart from it was clearly worse from a code-design perspective. I showed it to the experienced developer and he said that was how he imagined it. I was baffled, but this is what the managers asked for. The release got delayed a week because the tester had to retest everything. So in the end, we had just wasted days of time to make the code worse. Brilliant. If we had gone with my original fix, it would have taken the same amount of time, but the code would be better.

Additionally, we did highlight we couldn’t test all the third-party suppliers we integrate with, so we had “low confidence”… or there’s some uncertainty at least. However, the Directors got involved and they wanted it out. So out goes “V3”.

There was a problem with just one of the third-party suppliers, but for some reason, Support left the feature enabled for several hours, when they could have reverted it with my Config Switch. This led to many complaints (yet again), and therefore panic from the management. When it came to disabling it, despite being able to disable it for particular users, they turned it off for large groups.

We rollout our changes in phases, so the Software Delivery managers wanted me to rollback the changes once more before releasing to the next group of users. I asked why we couldn’t just use the Configuration Switch, and the response I got was “we don’t trust Deployment to turn the feature off. What if they miss some users?”

Well, when those users complain, you just switch the Configuration Switch to “off”. If we rollback again, then we are back to square one; where users can encounter the memory issue.

What is the point in coding a Configuration Switch if they won’t use it? I did point out the way the Configuration Tool works is that you could set the configuration ahead of time (the previous software version will just ignore the extra config), then when the users get the new version, then the updated version would use the configuration file as intended. So with a bit of persuasion, that’s the option they went for. However, they turned it off for every user, even if it wouldn’t have caused problems for them. 

When will they turn it back on?

Conclusion

It was actually a good idea to use a Configuration Switch. If the feature doesn’t work properly, you can quickly revert to the old way (well assuming your new changes don’t unintentionally break the existing feature). Obviously, you need to trust the Deployment team to actually use it correctly.

Colin went with a Configuration Switch for his recent project. How did he get on?

“The bug can’t be introduced by our project because it is switched off on live”.
5 mins later…
“This is definitely code that we changed”

Colin

Final Inspiration To Create This Blog

I noticed a folder in Outlook called Conversation History that has a log of all my conversations from when we used Skype. It’s a proper treasure trove of banter and funny stories. I’ll definitely be posting some of these conversations in the future.

I found this conversation pretty interesting. It’s from 6th February 2019. I checked the date when I started this blog. 6th February 2019

The Skype conversation starts off with me pasting in comments from a Code Review. Colin had fixed a minor issue, but hadn’t added a new Unit Test for this scenario. I had flagged him up on it.

I was ranting to a colleague about Colin’s response. Colin had thought I was asking if the existing unit tests have been run, rather than me asking him to write new tests for the new functionality.

Me 13:22:

         Me
         unit tests?
         Colin
         Not failing
 
 
oh that's ok then. Just fix a bug and don't cover the missing scenario
WHY DO I WORK HERE?

Colleague 13:22:
Why would you not write one??

Me 13:22:
it may fail if you write one

Colleague 13:23:
Lol
 
Me 13:27:
I might write a book on my programming experiences

Colleague 13:28:
Lol, I'm sure it'd be a bestseller 😛

I think I did consider the idea of starting a blog because I thought I had good stories to tell, and was ranting about stupid things my colleagues did. However, I wasn’t 100% convinced it was a good idea. It seems like my colleagues’ reply was the final motivation for writing about my experiences as a software developer. 2 years on, and I am still enjoying ranting, and feel I have plenty more stories to share.

C# Casting Nonsense

Introduction

I briefly mentioned the data types int (aka Int32) and long (aka Int64) in a previous blog Integer Overflow – Zaccaria Pinball. A key point is that the maximum value of an “Int32” type is 2,147,483,647, whereas “Int64” has a max of 9,223,372,036,854,775,807.

This blog is going to be more nerdy than my usual ramblings. It’s going to cover some C# code. In this blog, I’m going to show some interesting things that happen with Casting. Casting is defined by

A cast is a way of explicitly informing the compiler that you intend to make the conversion and that you are aware that data loss might occur, or the cast may fail at runtime.

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/casting-and-type-conversions

Simple Casts

Casting is done by putting the datatype in brackets next to the variable. Let’s see that in action.

We can begin with an Int32 (I’ll call my variable “anInt32”). Then on the next line, I will cast it to an Int64.

 Int32 anInt32 = 50;
 Int64 anInt64 = (Int64)anInt32;

We can also start with an Int64 (I’ll call it “anInt64”). On the next line, I will cast to an Int32

 Int64 anInt64 = 50;
 Int32 anInt32 = (Int32)anInt64;

The number 50 can fit in either Int32 or Int64. This works just as I intended. Nothing bad happens. But let’s move onto the more interesting scenarios.

Downcasting – Dataloss

So let’s create a large number and correctly store it in a Int64. Then we try and down-cast it into an Int32. It’s isn’t going to fit, so what happens to the number?

Int64 largeInt64 = 19992244551234;
Int32 intNumber = (Int32)largeInt64;

It overflows. The number stored in the variable “intNumber” becomes -828211646 and we have a bug. This is basically what happened in the Zaccaria Pinball example. The number was simply too big to fit in the space that an Int32 allows. If you are playing a computer game, it’s better than out-right crashing, I guess.

Casting With Objects

The previous examples show you can convert between Int32 and Int64 by casting.

Instead of being very specific with your variables, you could declare variables as the base type “Object”. Despite Objects being set to a number type such as Int32 or Int64, you can only successfully cast when the type matches, otherwise it will give you a runtime error, and say the “System.InvalidCastException: Specified cast is not valid.“. It’s quite a hard thing to explain, but let’s see it in action.

We first declare a variable of type “Object”. It is implicitly an Int32. Then on the next line, we cast it to Int64. In previous examples this would be fine, but as I try to explain in the previous paragraph, declaring it as an Object seems to play by different rules. Therefore the following code throws the InvalidCastException, since the declaration was implicitly an Int32.

Object intObject = 30024;
Int64 int64cast = (Int64)intObject;

So if we declare it explicitly as an Int64, then casting from Object to Int64 does work because the underlying type was an Int64:

 Object int64Object = 30024L; //explicitly an Int64 by using the L character
 Int64 int64cast = (Int64)int64Object;

But, similarly, as we saw in the previous failed example, casting it to an Int32 results in InvalidCastException, because the type does not match.

 Object int64Object = 30024L; //explicitly an Int64 by using the L character
 Int32 intcast = (Int32)int64Object;

Very frustrating and quite confusing! Earlier in the blog, I was showing you that if the original types were declared as a proper number types (Int32 and Int64), we can cast between them. However, when it was originally declared simply as an Object, we can’t seem to do this.

Convert to the rescue

Instead of casting, we can use Convert. These examples work as intended.

Object intObject = 30024;
Int64 int64convert = Convert.ToInt64(intObject);

Object int64Object = 30024;
int intconvert = Convert.ToInt32(int64Object);

Try It Yourself

Here is the full code to easily paste into Visual Studio (or your favourite IDE) and try it yourself.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Playground
{
	class CastingNonsense
	{
		internal static void Run()
		{
			Test1();
			Test2();
			Test3();
			Test4();
			Test5();
			Test6();
			Test7();
		}

		private static void Test1()
		{
			Int32 anInt32 = 50;
			Int64 anInt64 = (Int64)anInt32;
			//fine
		}

		private static void Test2()
		{
			Int64 anInt64 = 50;
			Int32 anInt32 = (Int32)anInt64;
			//fine
		}

		private static void Test3()
		{
			Int64 largeInt64 = 19992244551234;
			Int32 intNumber = (Int32)largeInt64;
			//overflows, but doesn't crash. Number becomes -828211646
		}

		private static void Test4()
		{
			Object intObject = 30024;
			Int64 int64cast = (Int64)intObject; //InvalidCastException
		}

		private static void Test5()
		{
			Object int64Object = 30024L; //explicitly an Int64 by using the L character
			Int64 int64cast = (Int64)int64Object;
		}

		private static void Test6()
		{
			Object int64Object = 30024L; //explicitly an Int64 by using the L character
			Int32 intcast = (Int32)int64Object;
		}

		private static void Test7()
		{
			//Convert solves the problem of casting. This works fine
			Object intObject = 30024;
			Int64 int64convert = Convert.ToInt64(intObject);

			Object int64Object = 30024;
			int intconvert = Convert.ToInt32(int64Object);
		}
	}
}

Integer Overflow – Zaccaria Pinball

Zaccaria Pinball is a pinball game you can buy on Steam. User Breeze posted this screenshot of his score: 1,947,658,906. A negative score!

 What happened is that he has reached the maximum score, then it suddenly becomes negative.

I don’t know what language Zaccaria Pinball is programmed in, but in C#, the maximum value of an “int” type is 2,147,483,647. So I imagine he has surpassed the current record, then suddenly it flipped to the record low score. He must be furious.

It is important you choose the correct datatype to store data correctly. Often on pinball games, people amass some crazy scores that you don’t think are possible, so it would probably make sense to go for the “long” type which has a max of 9,223,372,036,854,775,807. Hopefully the developers change this before annoying more players.

The secret features that Google didn’t want you to know

I do love a stupid clickbait title. These features are quite hidden though.

This particular link takes you to dice rolling app which would be good for board games. If you happen to lose your dice – then Google saves the day.

Google’s “Roll dice”

To switch to the other exciting apps, you can click the chevron, then there’s two tabs, GAMES AND TOYS, and TOOLS

Games and Toys

Earth Day Quiz

Tic tac toe

Snake

Spin a dreidel

Animal Sounds

Solitaire

Pac-Main

Minesweeper

Fun facts

Tools

Flip a coin

Meditate

Colour Picker

Calculator

Metronome

Spinner

As a bonus hidden feature, I always think Ngram Viewer is interesting when you want to get a rough idea how popular certain words are. Today, a colleague used the word “banjaxed” and I thought “that’s a very archaic word”. I think I had only heard it once and that was in a song (ALESTORM – Shipwrecked). It seems Alestorm used it at the peak of popularity.

For more secrets, check out The secret Touchpad features that Microsoft didn’t want you to know

The eight factors of happiness for developers

Maybe it is a bit philosophical and pretentious but I thought it was interesting. In many ways, it is like the antithesis of Stranger Coding Tings. For example, my blog is about thinking about past grudges, and venting frustration at things I can’t change. 

Check out the full blog here:

Simply posting a link probably wouldn’t be that exciting and entice you to read it, but pasting the full article is just plagiarism – so I’ve put together a summary from the opening lines in each section as a compromise:

1. Resentment

Harboring resentment or anger toward another team member can be a significant source of unhappiness. 

2. Not living in the past

Don’t dwell on that job that you didn’t get or that project that went bad. If we live in the past, we are doomed to repeat it. As developers, we need short memories and one of the best ways we learn is through failure. 

3. Cooperate with life

The Serenity Prayer asks us to accept the things we cannot change, change the things we can, but also have the wisdom to know the difference.

4. Stay engaged with the real world

As developers, it’s easy to withdraw into our own world. It’s often a reclusive profession, and without even trying, we can have very little interaction with others. But humans are social creatures.

5. Love yourself (and others)

Programming is hard and don’t let anyone tell you it’s not. The problem is coding is a technical skill and there are rock stars and ninjas, and there is the rest of us (I’m in this camp). We must have empathy for ourselves and others as we move around in this profession.

6. Be virtuous

As engineers, we live in a highly technical environment so we think that gives us a pass on virtues like love, compassion, and empathy. 

7. Lower your expectations of yourself

Shoot for the moon, if you miss, at least you will be among the stars. We’ve all heard this a million times, but, as I said earlier, coding is hard, so I am going to propose that we cut ourselves some slack and don’t expect so much. Just by virtue of our chosen profession, we are overachievers and we make things doubly hard when we expect to progress too fast.

8. Serve something bigger than yourself

Self-centered and narcissistic people are the least happy people on the planet. The happiest people have found some balance between serving and caring for themselves and serving their family, their co-workers, and those in their community. I once heard someone describe the three pillars of human happiness as fulfilling the need for meaningful work, the need for lifelong connections, and the need to serve something bigger than yourself.

Skeletons In The Attic

I was on a call and one guy turned his webcam on. He has a full-sized skeleton behind him. He leans back in his chair and stretches. I was wondering if he was trying to “stealthily” cover it up. Shortly, he turned his webcam off. Later in the call, he turns it back on, and the skeleton was nowhere to be seen. So maybe he was trying to cover it up afterall.

Teh

I remember back in the early noughties, lolspeak became a thing which included intentionally poor grammar – so you would write “teh” instead of “the”. (There was l33tspeak too where you’d intentionally switch out letters for numbers).

I can understand making this (“teh”) typo occasionally, although most people would notice and correct it before sending. When there is a red, squiggly line under the word, then surely you are going to accept the spelling suggestion rather than ignoring it and sending the message anyway.

There is one colleague that constantly writes “teh”. I think they only correctly write “the” maybe 10% of the time. I find it infuriating. 

Maybe it is a boring blog, but I just wanted to illustrate what I have to endure:

  • Was an email sent to her around teh requirements, I know there was teh one from Rob for the first part
  • works for teh other test box
  • I restarted teh box
  • I still get teh invalid URI message in error logs so it has to be something to do with that
  • ok so teh deprecate button
  • where do you set teh trusted connection to true?
  • at least teh doc is now up to date
  • Yep missed teh bit at teh end
  • I noticed last night that teh service was down….that’s another issue that I’m unsure of teh error message is around network so thought it might have rectified on it’s own by this morning
  • this is teh deployment section where teh token is incorrect
  • PC in teh office
  • is this to do with teh last bug fix?
  • give me a sec, just logging on again to get teh message
  • and can’t link teh user
  • i get teh warning banner
  • is it a case of changing teh ID code of the user?
  • From teh list of entries i provided above is any valid entries?
  • Do we all have visibility of teh top 25?
  • Nope didn’t enter teh wrong pin
  • Always happens when I leave teh office
  • I can see teh docs on teh server
  • Currently our test system doesn’t fully bring across teh docs
  • hey guys don’t forgat that teh meeting is now
  • Is there some comms around teh powercut
  • teh watermark flashed up…doesn’t seem right
  • I would imagine it shows in teh preview