fbpx

Writing Good Unit Tests; Don’t Mock Database Connections

Writing Good Unit Tests; Don't Use Database Mocking

Unit tests are unbelievably important to us as developers because they allow us to demonstrate the correctness of the code we’ve written. More importantly, unit tests allow us to make updates to our code base with the confidence that we haven’t broken anything. In our eagerness to get 100% code coverage, however, we often write … Read more

The Nuances of Constants in Go; Go Isn’t JavaScript

The Nuances of Constants in Go; Go Isn't JavaScript

Constants can be confusing and easy to misuse in Go if you are coming from an untyped language. Let’s take a look at some of the nuanced details of how they work in Go. It’s probably unsurprising, but Go’s constants are almost nothing like JavaScript’s bastardized version of the concept. Go vs JavaScript Many programming … Read more

Practical Patterns for Technical Writing

Practical Patterns for Techincal Writing

Writing technical documents like API or architectural documentation which exceeds a simple flow diagram can be a daunting task. If you have some experience with technical documents, you will probably agree that there is nothing more frustrating than bad documentation. Lately, technical writing has become a more important part of my job, so I put … Read more

How to Make Pure Functions (Go)

Pure Functions in Go

Pure functions are often hyped up in the JavaScript world, probably because of the abundance of stateful front end applications. While pure functions have their downsides (i.e. inconvenience, potentially large argument lists), they should be used as much as reasonably possible. We’ve made a lot of changes in the Qvault app codebase recently to use … Read more

Guard Clauses – How to Clean up Conditionals

Guard Clauses - How to Clean up Conditionals

One of the first concepts new developers learn is the if/else statement. If/else statements are the most common way to execute conditional logic. However, complex and nested if/else statements can quickly become a cognitive burden and compromise the readability of a program. Guard Clauses Guard Clauses leverage the ability to return early from a function … Read more

Should You Return Empty or Nil Slices in Go?

Empty vs Nil Slices in Go

In Go, we often need to return zero values. Idiomatic Go encourages the use of guard clauses, and guard clauses necessitate the need to return early. When returning early with an error, by convention all other return values should be zero values. The confusion arises with data types like maps and slices. Should maps and … Read more

Slow Is Smooth, Smooth Is Fast – 25% of Our Time Refactoring

Slow Is Smooth, Smooth Is Fast - Refactoring

My team at Qvault has been spending less of our “free” time working on bugs and features from the backlog, and more time refactoring our codebases and test suites. As a result, and perhaps somewhat counterintuitively, we’ve noticed a significant increase in our throughput of features and bug fixes. As it turns out, its easy … Read more

Optimize For Simplicity First

KISS keep it simple stupid

We can’t optimize for everything in software engineering, so we need to start with something, and that something should be simple code and simple architecture. For example, to over-optimize for speed in JavaScript, we might write our for-loops backward to the detriment of readability. On other occasions, we may over-optimize architectural abstraction to the detriment … Read more

Make, New and Literals Cheat Sheet – Slice and Map Initialization in Go

golang gopher slice literal

There are quite a few ways to create new maps and slices in Go, for example, they can both be initialized using the make or new functions, as literals, or using the var keyword., but which option is best? Or perhaps better asked, which one is best in your situation? Let’s take a look. Slices … Read more