fields, methods and constructors in enums

Today I learned about Java's enum types can have fields, methods and constructors. This makes them more versatile than the enums I'm familiar with from other languages, and unless I'm misunderstanding something, it essentially means that they inherit from the enum they're defined in, letting us have custom functionality per type. I've already found a use case for that at work, and I'm sure more is to come! More about Java's enums at Baeldung.

2025-04-01

command pattern

Today, while reading peetseater's blag, I stumbled across a link to a chapter in Robert Nystrom's "Game Programming Patterns" book on the Command pattern. While I had a knee-jerk reaction at first due to how many layers of abstraction it introduces, the examples made it clear when it might be useful to compose the code in such a way. I've yet to make any actual games that are bigger than a few hundred lines of code, but I'm definitely gonna be getting back to that book and checking it out when I embark on a more serious project.

2025-03-23

cosmic rays

Today I learned more about how cosmic rays impact technology, and how modern systems protect against them. I knew about the Mario speedrun that has likely been impacted by them, but not much more than that or the physics behind the phenomenon. Veritasium's video shed a bunch of light on the topic for me, I highly recommend checking it out.

2025-03-20

line endings

Spotless (Java formatting library) messed with my line endings a little, and so I had to figure out a way to renormalize them in Git. The comprehensive way to do so seems to be as follows. Firstly, set git config --global core.autocrlf false. It might be true on Windows by default. Secondly, configure Git's line endings to default to LF with git config --global core.eol lf. Lastly, git add --update --renormalize will normalize the line endings in every file tracked by Git.

2025-03-19

responsive grid trickery

Today I learned about grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); which lets you easily create a responsive grid. This particular example calculates how many 450px-wide columns can fit on your screen, and adjusts the column count accordingly. See more on MDN.

2025-03-17

Paths.get

Today I learned about Java's Paths.get that provides a cross-platform utility to assemble Path objects from strings or URIs. The resulting interface contains many common methods to work with file paths. See: documentation on Paths.get and Path.