Crafting in Java

Gerard Szczepanski

Test harness with git pre-commit — March 29, 2018

Test harness with git pre-commit

rocket-rocket-launch-smoke-73871

cropped-button Introduction

Have you ever encounter situation that you, or any of your colleagues commit code, that was not working?

It could be a class with missing semicolon, that causes compile failure on deploy.
It could be small change that changed system behavior that made unit tests fail.
Or worse… it could be changed behavior that was not discovered until the user encounters it.

It happened to me several times that I or someone else did not check projects’ build after merge/rebase to master branch and just pushed changes to remote. It is not safe, and should be prevented.

How? Let me introduce you pre-commit git hook.

Continue reading

Cleaning up Domain with Domain Registry — March 25, 2018

Cleaning up Domain with Domain Registry

blur-bright-bulb-131023

cropped-button Introduction

I’ve recently read again excellent Implementing Domain Driven Design book by Vaughn Vernon. He presents there a lot of examples for domain objects, services and other components. I spotted a nice pattern that he uses for them – Domain Registry.

I stared to use this pattern in my newest code task.
I want to show you usecases and discuss about this alternative way to resolve dependencies…

Continue reading

Tickets Reservation System Kata — March 21, 2018
Test Harness (Treat your components badly) — February 11, 2018

Test Harness (Treat your components badly)

cropped-button Introduction

Writing code is always fun. Seeing written code that is actually working is much more fun. I like to see that the process that I wrote gives me expecting result.
I like to test happy path and use my component as soon as possible.

Back in the days I used to treat my application gently…

But we shouldn’t treat our applications gently.
We should crush them, beat them, make them suffer.
We should put them into test harness, always expecting the worst.

Continue reading

Refactoring Legacy Code – Episode I — January 6, 2018

Refactoring Legacy Code – Episode I

ss_12036337fe569dee7853cdd275808b49c0f7339d.1920x1080

cropped-button Introduction

I’ve recently came across nice, small project in Java, which is an attempt to recreate one of my childhood game – RollerCoaster Tycoon. Project was uploaded on Sourceforge in 2016 and has some basic features of original game. I though it
is a nice occasion to dive into code and learn something – since I always wanted to learn math of 2D isometric games, and this project seems to have good isomethric algorithms.

So I look at the code… And I thought that I need to do some refactor to understand the project.

Continue reading

Facade Pattern squeezed — May 8, 2017

Facade Pattern squeezed

cropped-button Introduction

Facade pattern is structural design pattern, that hides complexity of the system components, wrapping them into one class with well designed, simplified interface.

When I first read Design Patterns [GoF] I was charmed by a lot of patterns introduced by authors. Some of them I was known earlier (like Abstract Factory or Observer), but most of them were new concepts for me. One of the easiest pattern to assimilate and use was Facade pattern which I want to discuss.

Continue reading