Factorio mods

Recently, I have been playing Factorio again after a long break. A lot of new things added and a lot of improvements, but also a number of things removed and bugs existing for years classified as minor and never fixed. Luckily, there is a modding API that I have been experimenting with recently. You can see my Lua efforts in my GitHub.

Read the rest of this entry

IntelliJ’s settings worth changing

IntelliJ is a very complex tool, with thousands of different settings, templates, customisations… Possibilities are endless, but there are a few check boxes that I would consider quick wins – changing them won’t take much of your time, but it can make a big difference to the way you work.

Read the rest of this entry

Java 8 hands-on workshop

Recently I have organised a hands-on Java 8 workshop in Capita. The exercises are available in my GitHub repository. No matter your level, I think you can still learn something from it. It starts with basics such as lambdas and methods references, through Optionals, until finally reaching various Streams and gradually introducing their methods.

How to compare Java objects in tests

If you followed my blog or looked at any of my projects, you probably noticed that I am a big fan of Shazamcrest. I have introduced this library in every project I worked on, whether it’s personal or at work. Recently I came across AssertJ‘s isEqualToComparingFieldByField(...) which tries to achieve something similar. All of these frameworks have certain problems that I would like to show you. I would also like to show you how easy it is to implement a good assertion method yourself.

Read the rest of this entry

My first artifact in Maven Central Repository

My MapToObjectConverter finally made it to Maven Central Repository. You can try it out by just adding a dependency:


Introducing static typing

As a Software Engineer consultant in Zuhlke, I have an opportunity to work on various projects in various stages of development. Recently I have joined another existing project and I have found out again that we use Map<String, Object> too much, instead of mapping the objects to classes and benefit from all the goods of static typing. I think I have never before appreciated how powerful static typing is, and how much the lack of it can hurt (maybe that’s why I prefer to use Java over JavaScript?). The main reason for us to use maps is jdbi – we execute the SQL, we get back List<Map<String, Object>>. But mapping it to objects is too much effort so instead we keep working with maps. But what if mapping could be trivial and painless?

Read the rest of this entry

Diamond Kata in Java

Someone recently has sent me Nat Pryce’s blog post with his property test driven approach to diamond kata. I had a quick look and decided to try diamond kata myself.

Read the rest of this entry

Bad Practices of Testing presentation

Recently I gave a presentation called “Bad Practices of Testing”. It shows the most common mistakes done while writing tests, describes problems they cause and shows how to do it better. Slides are done using github markdown so you can read it online here: https://github.com/Jarcionek/Bad-Practices-of-Testing

Random number generator using modulo

You have probably heard about modulo bias using random number generator. If you read Effective Java by Joshua Bloch this problem is described in Item 47. But did you ever think why there is a problem with simple code like this Math.abs(rnd.nextInt()) % n ? Why the distribution of elements is not equal and by how much is it exactly biased? Here is the mathematical explanation:

Read the rest of this entry

What to mock and why not to mock data objects?

Recently when reviewing my code before opening a pull request, I have noticed a few methods that I felt were untested. I have run all tests with coverage and indeed 7 methods in the class were not covered. The class was a data object and all these 7 methods were mostly getters and setters so the following questions arose:

  • Should I have a unit test for data object?
  • Should I be testing getters and setters?
  • Why I never had to do this before?

Read the rest of this entry