Skip to content

Instantly share code, notes, and snippets.

View MatusMak's full-sized avatar

MatusMak

  • nordics.io
  • Košice, Slovakia
View GitHub Profile
@MatusMak
MatusMak / nicer-logger.md
Created December 2, 2019 13:13
Utilizing functional principles to make simple things such as logging more enjoyable

Recently, I came across a scenario where I had to log a list of entries whenever that list was not empty. Basically, I was removing invalid data that I have received from outside and I wanted to warn about this in a case users would complain they are missing these entries.

Anyway, I had to do an equivalent of this several times in a row:

if (anyCondition) {
    logger.warn("Hey, something is not okay!");
}
@MatusMak
MatusMak / Java - working with nulls.md
Last active November 29, 2019 22:23
Working in Java with nulls. There is no easy and straightforward way of working with nulls in Java in comparison to other languages, like Kotlin or C#. This is my thought experiment on how to solve this with a very simple helper methods.

IMPORANT! This is my thought experiment, which may or may not be valid. Feel free to comment and give your insights, but think twice before using any of my custom solutions in your code! Always prefer using language's functionality if possible.


There are specific use cases where you always have to check if a variable is null, for example, when working with database:

Connection connection = null;
PreparedStatement statement = null;