Let’s make code SOLID: Conway’s Game of Life

Our online Coding Dojo sessions became the most powerful learning experience for me, and recently we came across Conway’s Game of Life.

I remember playing this game on paper when I was a child. Yesterday I had the pleasure to code the rules and see them working.

To make it more fun, we in our Coding Dojo club decided to separate concerns between “cells” and “grid” where the cells exist. After an exciting discussion for which I am grateful to Dennis, Saeed and Byron, I had started an all-nighter.

Here is what I got with a sunrise:

Conclusion:

I can not deny that SOLID code has its price. It takes much more time (2x or maybe 3x to compare to writing a monolithic code).
Nevertheless, we get benefits such as extensibility and reusability.

Let’s say we want to run the same game in 3D space. We can easily make this modification with SOLID code.

Leave a Reply

Your email address will not be published.