Categories
Architecture Software

The Value of “Value Objects”

Herberto Graça recently wrote a great summary on Value Objects, and I commented on it on Reddit, saying: …something that could flesh out the case for value objects [is] the fact that it allows you to model complex rule interactions by representing the concepts of the core domain and letting them interact as they would […]

Categories
Architecture

Don’t call your interfaces interfaces

An old, prolific convention of software development has been to prefix or suffix interfaces with something that specifically designates them as such. So if I have an interface for a clock, rather than calling it Clock, many would call it IClock or ClockInterface. In PHP, the convention is so ingrained that our core inter-framework operable […]

Categories
Design Patterns

Why I love the repository pattern

Persisting application state is not an easy job, to say the very least. We have an entire cottage industry of vendors who promise to simplify these issues for us. But there is a long-existing design pattern that which provides a logical separation in your application to help tackle this problem, without needing to commit to […]

Categories
Design Patterns

Code Smells: Static References to Time

So you need to do some time-specific calculations in your application. It’s related to the current time, so you do the usual thing, and new up a DateTime object: $now = new DateTime(); Seems innocuous, right? But you quickly run into some pretty nasty problems: Your code is now very difficult to test reliably. To […]