Here are some rules I use for working with dynamic arrays. It's pretty much a Style Guide for Array Design, but it didn't feel right to add it to the Object Design Style Guide, because not every object-oriented language has dynamic arrays. The examples in this post are written in PHP, because PHP is pretty much Java (which might be familiar), but with dynamic arrays instead of built-in collection classes and interfaces.
Today Manning released my latest book! It's called "Object Design Style Guide".
In November 2018 I started working on this book. The idea for it came from a conversation I had with the friendly folks at Akeneo (Nantes) earlier that year. It turned out that, after days of high level training on web application architecture and Domain-Driven Design, there was a need for some kind of manual for low level object-oriented programming. Not as low level as the kind of programming advice people usually refer to as clean code, but general programming rules for different kinds of objects. For instance:
- A service gets its dependencies and configuration values injected as constructor arguments.
- A service is an immutable object.
- An entity always has a named constructor.
- An entity is the only type of mutable object in an application.
And so on...
This blog runs on Sculpin, a static site generator. The generator itself runs on Symfony, which for me makes it easy to extend. However, I find that if you want something special, it can usually be done, but it may take several hours to get it right. In the end though, the solution is often quite elegant.
A custom content type for events
One custom feature I wanted for this website was a list of events (conference talks, trainings, etc.). Sculpin's documentation suggests using a custom content type for that. This allows you to create a directory with files, each of which will be considered an "event".