Why and How to write better Unit Tests

TL;DR Good unit tests build the foundation of a maintainable and high-quality codebase Unit Tests should help developers to be productive Unit Tests should be fast Unit Tests should be isolated Unit Tests should be deterministic Unit Tests should focus on a single unit Unit Tests should be enduring Unit Tests should be clear, concise and complete Avoid complex control flow logic like nested ifs or loops Unit Tests should follow a consistent naming pattern like UnitName_StateUnderTest_ExpectedBehavior Unit Tests should comply to a consistent structure Unit Tests should be DAMP not DRY Unit Tests should give developers confidence to deploy and to refactor Test Doubles help to make tests fast and deterministic The overuse of Mocking makes test hard to read and brittle Prefer state verification over interaction verification Prevent brittle tests Prevent flaky tests Read more: Software Engineering at Google Kent Becks’s Programmer Test Principles Microsoft’s Best Practices for Unit testing Why good unit tests are important TDD and test engineering culture is considered best practice these days....

May 4, 2020 · 20 min · Daniel Gerlach

ESlint + Prettier + Typescript = Consistency

Consistency is one of the most important factors in a codebase. It gives new developers an orientation and direction how to write new code. It keeps the code understandable, clear and free from bikeshedding, so developers can focus on real problems instead of indulging in discussions on their preferred codestyle and individual taste. Consistency can be pertained by strict discipline but if possible you should enforce good style and formatting via opinionated code formatters like Prettier which makes development and collaboration a breeze....

March 24, 2020 · 7 min · Daniel Gerlach

Install Postgres on Ubuntu

Recently i decided to switch from MacOS to Linux. I was already an Ubuntu user from 2006 till 2015. So i am used to Linux. Nevertheless i struggled a little bit with the installation of PostgreSQL. For MacOS there is a nice all-in-one package which i recommend: Postgres.app. Everything works out-of-the-box there. In Ubuntu, on the other hand, we need to adjust the default installation a little bit in order to start application development....

July 26, 2019 · 4 min · Daniel Gerlach

Emacs Delete Lines

Sometimes when i write small scripts i tend to insert print statements for debugging. After i verified the correctness of my program i want to get rid of all unnecessary debug statements. With Emacs you can delete all lines which match a specific regular expression with M-x flush-lines or with its alias M-x delete-matching-lines. Interactively you can enter your regular expression and all matching lines will be deleted from you cursor position downwards....

May 13, 2019 · 1 min · Daniel Gerlach

Install Emacs on MacOS

Yesterday Emacs 26.2 was released, see: https://www.gnu.org/software/emacs/news/NEWS.26.2 In this short guide i want to show how i install Emacs on my MacBook. I use the vanilla Emacs build from https://emacsformacosx.com/. It is just a simple .dmg file. After installing the dmg file, Emacs is now available on your Mac as an application but not in the terminal-app. The terminal still opens the pre-install Emacs version. To make the new version available you have to create a bash-script and put it in your $PATH....

April 13, 2019 · 2 min · Daniel Gerlach

Find and Replace in multiple files

As a software programmer you often have to search and replace a specific string in multiple files because of a refactoring or just improving a variable or function name. Normally you can use your IDE or your editor for this. But in bigger codebases with thousand or million lines of code it can be very slow. Neither do IDEs work with remote SSH-sessions. In such situations the command-line is pretty handy....

April 13, 2019 · 1 min · Daniel Gerlach

ag the_silver_searcher, a grep replacement

As a programmer you often search for a specific strings or regexps in multiple files. Previously i used to do this with the well-known GNU-tools find and grep. The following command searches for main in all *.go files in the current directory and: 1 2 find . -iname '*.go' | xargs grep -inH "main" # -i ignore case, -n print line number, -H print filename Recently i discovered ag the silver searcher....

April 13, 2019 · 1 min · Daniel Gerlach

Emacs Test Regexps

Replacing or searching text with regular expressions is very common. But sometimes it is hard to get them right and you need some playground to try them out. In order to verify regular expressions i used to visit webpages like: https://regexr.com/ https://regex101.com/ But these webpages are optimised for perl, javascript or bash expressions and do not support Emacs regular expressions directly. In Emacs you have to consider some peculiarities....

April 6, 2019 · 1 min · Daniel Gerlach

Things to consider with microservices

Introduction Some years ago i was involved in migrating a big IBM Websphere monolith into a microservice landscape. We had a lot of problems with the monolith. Our development speed slowed down. We had many merge conflicts because of too many dependencies in the codebase. We outgrew the monolithic design and decided to introduce microservices. We extracted different domains like payment, booking, user and search. The teams were restructured into two-pizza teams....

March 30, 2019 · 7 min · Daniel Gerlach

My Presentations

Links to my presentation slides clojure introduction javascript introduction java8 new features hashicorp nomad tutorial

March 16, 2019 · 1 min · Daniel Gerlach