It’s All Or Nothing, Part 2

Every once in a while, it’s time to get a raise. With inflation, and a growing skill set, it makes sense.

As a contractor, I usually stick to one of two opportunities to secure a rate increase. I would ask for a higher rate when assigned greater responsibility. I would also increase my rate when switching contracts.

Let’s focus on the first scenario. When I ask for a rate increase, I do so risking everything. If I’m turned down, I terminate the contract.

You cannot ask for anything without willing to fully commit to using your leverage. False promises dent your credibility. If you ask for anything and don’t get it, there must be consequences. Accept not getting what you asked for, and be ready to never get it.

What reason does anyone have for giving you what you want? Clearly nothing happens if you are turned down. Business is business, right?

So either ask for what you think you deserve, willing to act if turned down, or don’t ask. Otherwise, there IS harm in trying.

So Predictable

Good code should have test coverage.

However, writing tests is not a box-ticking exercise.

If tests are not written well, they are not helpful. One characteristic of a good test is that its results are consistently reproducible. This helps us see what the problem is every time we run the test.

There is a common mistake I see developers make. Trying to cover a wide range of scenarios, they use a random value in their tests.

To be clear, I am referring to run-time generated random values, not random values generated in advance and hardcoded into the test. The latter can be fine.

When you use random values in your tests, you may end up with flaky tests. Your tests may pass some of the time, and fail at other times.

Both scenarios are bad. If the tests pass, you may have missed out on a bug. Your tests no longer give you confidence. If the tests fail, you don’t know what values made them fail. Will they fail when you run them? Maybe. Maybe not. Maybe only after you ran them ten times. This is time-consuming.

You get the idea. Tests should be boringly predictable. If you want to test multiple values, test them all. Use a parameterized test. Use a loop. Don’t use random values.

Testing should give you confidence. Keep them predictable. If you want the adrenaline rush of gambling, go to Vegas. I hear it’s lovely this time of year.

Beauty And The Beast

I was recently interviewed for a new contract. One of the questions I was asked was this: which would I say was more important: beautiful code or a good, polished UX.

I found it to be a very important question. Paraphrasing, this was my answer:

Beauty is in the eye of the beholder. We should first define what beautiful code is. For me, beautiful code is clean code. It’s maintainable code. It’s easy to understand. It has good test coverage.

And so, I would argue beautiful code is more important.

The reason is quite simple: with clean code, introducing new features becomes easy. You are less likely to introduce regressions. Fixing bugs becomes easier, too.

This all translates to a better product for the end user. And so, by prioritising beautiful code, you gained both goals: beautiful code AND a better UX. Consistently.

The opposite is not true: if you prioritise UX and knowingly neglect code quality, you will soon realise you’ve made a mistake.

Adding features would become a daunting task. New bugs would frequently occur. Fixing new and existing bugs will become a nightmare. The product will become a scary beast.

Eventually, the user experience would suffer. You will end up losing both goals.

And so, my choice would always be to go with beautiful code. I’d rather not meet the beast.

Bonjour Monsieur

I love learning new things. Learning something new makes me feel like I’m becoming a better verision of myself. I suddenly have new tools for problem solving.

One thing I’ve always wanted to learn was French.

At school, half the the students were set to learn French, and the other half to learn Arabic. Since most of my family spoke French, I wanted to learn French.

I was put in the Arabic class.

Leave it to the education system to mess things up. No matter how much I protested, and despite there being kids who’d happily trade places with me, they wouldn’t budge. So, being a stubborn kid, I ended up learning neither.

Every once in a while, I’d give it a go. I tried multiple apps (ahem, Duolingo). None clicked for me. I guess different people learn differently.

Luckily, I married a teacher. With the help of my wife, I gave it another go. I started making real progress when my wife introduced me to Memrise.

Memrise really works for me. It’s practical, focusing on everyday words and sentences. It’s friendly, with videos of locals pronouncing common sentences. It’s progress system makes sense to me. I could do with less promotional ads, but for a free app I guess I can put up with it.

I still have a lot to learn, but I’m making good progress now, which is exciting. Mon dieu!

Three Files To Go, Please

I recently switched from a MacBook to a Windows laptop. There were a few Mac features I really liked and was missing on Windows.

One such feature is the ability to select multiple files, right click them and move them to a new folder. If you want this functionality on Windows, it’s your lucky day!

With a few steps, you can add a “Send to New folder” context menu option to your Windows Explorer. Ready? Here we go:

  1. Create a new text file anywhere. I created mine under C:\Program Files – but anywhere would do. Name the file Send To New folder.cmd.
  2. Open the file in Notepad (or your favorite editor) and paste the following in:
@echo off
cd /D "%~dp1"
setlocal EnableDelayedExpansion
set "baseName=New Folder"
set "n=0"
for /f "delims=" %%F in (
  '2^>nul dir /b /ad "%baseName% *."'
) do (
  set "name=%%F"
  set "name=!name:*%baseName% (=!"
  if !name! gtr !n! set "n=!name!"
set /a n+=1
md "%baseName% (%n%)"
set argCount=0
for %%x in (%*) do (
  set /A argCount+=1
  set "argVec[!argCount!]=%%~x"
for /L %%i in (1,1,%argCount%) do move "!argVec[%%i]!" "%baseName% (%n%)"
explorer /select,"%baseName% (%n%)"
  1. Next, press the Windows Key + R. Type shell:sendto into the field and press Enter.
  2. Drag the Send To New folder.cmd file you created earlier to the newly opened folder while holding the Alt key. This will create a shortcut in your Send To context menu.
  3. Rename the newly created shortcut to New folder.

That’s it! Now, to move files to a new folder, select them in Windows Explorer. Right-click, then select Send to -> New folder. Voila!

Choose Your Weapon Wisely

I love gadgets. I’ve always loved them. I don’t discriminate, either. Small gadgets, large gadgets, technological gadgets, non-technological ones. I love them all.

Given enough resources, I’d probably own every gadget in existence. For a while, I was heading in that directions. Fidget toys, USB dongles, tiny computers, Swiss army knives… I got them all.

And then I realised I do have constraints. Financial limits, storage space limits and even time limits. So getting more gadgets stopped providing more value for me.

When I look at a gadget now, I start thinking. Do I need it? Will it serve me? Do I have where to put it? Will I actually have the time to use it? Does it even work?

I find in most cases, this stops me from making an emotional buy. I still buy gadgets. But now, I am a lot more picky. I really don’t need another spinning fidget. I won’t have time to program that new micro-computer.

What gadgets have you regretted buying? Which ones are you glad you bought, or didn’t buy?

I’ll Totally Give It Back

British landlords have a national sport. It’s called “keeping as much of your deposit at the end of the tenancy as possible”. Not very catchy, I know. But it’s a sport nonetheless. If you rent in the UK, you know what I’m talking about.

When you move out, a British landlord will make every effort to keep as much as possible from your deposit. They’ll quote the most expensive cleaners. They’ll charge you a fortune for menial tasks such as moving a chair from one room to the other (I’m not making this up).

I’ve had a lot of experience with this as a renter. I learned a few things:

– Try and leave the flat in the best state possible. No burnt light bulbs. Clean carpets. No holes in the walls.

– Report any faults as soon as you encounter them throughout your tenancy. Be especially pedantic as soon as you move in.

– When facing the landlord’s attempt to keep the money, challenge everything. Prove (using quotes) the market rates for cleaning. Prove the cost of anything that needs replacing.

– Prepare to only get part of your deposit back.

To win in any sport you have to put an effort in. This is no different. Try your best. You could save thousands of pounds.

You’re Wrong

I’m a critical person. I’m also a perfectionist. While this doesn’t mean I don’t make mistakes, it does mean I have an urge to fix mistakes when I see them.

One common place to find mistakes on is people’s posts, tweets and status updates. I used to correct them in a comment. I didn’t give it much thought, really. If I saw a typo, I’d comment on it. Bad use of the language? I’d comment on it.

It wasn’t until I saw someone else doing the same that it hit me. They corrected a person online. The person replied, saying they were dyslexic. They said the correction could have been made in private rather than public shaming them.

It hit me hard. For years, I was feeding my own ego at others’ expense. I was public shaming friends (and strangers) to show off my superior intellect. How poor a behavior this suddenly seemed.

From that moment onwards, I stopped. I would send friends a private message if they made a mistake. This gives them a chance to rectify it without the public shaming.

It changed how I do code reviews, too. I try to be softer in my criticism now. If I have harsh feedback, I send it to the person privately. It doesn’t mean I stopped flagging mistakes in code reviews, of course. But I always keep the lesson I learned in the back of my mind. I’m reviewing a person’s work. They have feelings, and they could get hurt.

My advice to you? If you are like me and are bothered by people’s mistakes, keep your feedback discreet.

You can read more about this approach in the highly recommended How to Win Friends and Influence People by Dale Carnegie. This is a book I recommended before but is worth mentioning again. It truly can change how you interact with people and how they respond to you.

I may get commissions for purchases made through links in this post.

So Much Cache

I’ve moved homes many times. Every time I moved, it seemed I had more stuff to move than the time before.

None of it was useless. Well, most of it wasn’t. More kitchenware. More furniture. More books. More clothes.

It all meant I needed a bigger place. Every time. Just so that I could live with all my stuff.

Some people are lucky enough to have a shed or a garage where they can store stuff they don’t need right now. None of my places had the extra storage space.

The last time I moved was especially challenging. There was a week’s gap between the time I had to vacate the previous flat and the time I could move into the new one. A week during which I had to put all my stuff somewhere.

So I rented a storage unit for a week. I was never aware this service existed before! Here’s what I learned:

– Storage units can be very affordable.

– Storage units can be huge.

Now, when I’m considering my next home, I can go smaller. I can store the things I don’t need immediate access to in a cheap storage unit. Why pay for an expensive property only to store stuff?

This is how cache works, too. You store the stuff you don’t need right now in a fairly accessible, fairly cheap storage space.

So if you’re anything at all like me, consider getting a storage unit. It’s an easy way to make your home bigger.

What Else?

As software developers, one tool at our disposal, in almost any language, is a switch expression. It comes in many forms: switch, case, when… They are all fundamentally the same. Given a value of an enumerated type, it defines the code behavior for each such possible value.

In Clean Code, Uncle Bob suggests we make sure to only switch over a value once. The idea is once you’ve determined the value, you can convert it to a class with the required behavior. From that point onwards, you can use that class, and not care why it behaves the way it does.

This advice is especially valuable when you need to add another possible value to your enumerated type (or change one of the existing ones). If you haven’t followed the above advice, you’ll end up changing a lot of switch statements. For each one, you’d have to figure out the new expected behavior.

What’s worse, you may not remember all places you need to update. This is because, even though a lot of languages give us some compile-time safety for switch statements, they also allow us to cover all cases we (currently) don’t care about using an else. With an else in place, the code is still valid after adding new values.

This is a problem, because we may want to handle those values differently. With the else in place, we get no warning. It’s amazingly easy to introduce new bugs this way.

So, long story short: if you’re using a switch expression, try to only do it once. Regardless of how many times you end up switching over your values, avoid else. Specify each value explicitly. If you’re lucky enough to have support in your language for grouping values, you can use that to tidy things up.

But no else. Or else…

I may get commissions for purchases made through links in this post.