PHPNews

Precision Through Imprecision: Improving Time Objects

Written by Ross Tuck - Published on Ross Tuck's weblog
Aggregated on Thursday August 10, 2017 - Permalink

tl;dr When creating value objects representing time, I recommend choosing how finegrained the time should be with your domain experts and round it off to that precision in the value object. When modeling important numbers, it’s considered good form to specify the precision. Whether it’s money, size or weight; you’ll typically round off to a given decimal point. Even if it’s only for user …

Continue reading »


Formatting Exception Messages

Written by Ross Tuck - Published on Ross Tuck's weblog
Aggregated on Tuesday October 27, 2015 - Permalink

Over the last couple years, I’ve started putting my Exception messages inside static methods on custom exception classes. This is hardly a new trick, Doctrine’s been doing it for the better part of a decade . Still, many folks are surprised by it, so this article explains the how and why. How does it work? Let’s say you’re writing a large CSV import and you stumble across an invalid row, …

Continue reading »


PHP 5.3 Closures and Reflection

Written by Ross Tuck - Published on Ross Tuck's weblog
Aggregated on Monday July 6, 2009 - Permalink

Note This post is outdated (2009). Specifically, the Callable typehint and Closure typehints should be preferred to is_callable && is_object. You can also use $this inside anonymous functions from 5.4 as well. One of the things I’ve been really looking forward to in PHP 5.3 is seeing what I could do with closures. There’s some handy obvious use cases (strategy object substitute…

Continue reading »


Raphael Roundup

Written by Ross Tuck - Published on Ross Tuck's weblog
Aggregated on Thursday December 19, 2013 - Permalink

Some recent converations prompted me to gather some of my recent Raphael related links in one place. For starters, my introductory article to Raphael “Pretty, Pretty Pictures” was published in this month's PHPArchitect . For a more in-depth look, NEPHP recorded my presentation on the subject “Team Plaatjes” earlier this year. Or just checkout the …

Continue reading »


ETags for the Uninitiated

Written by Ross Tuck - Published on Ross Tuck's weblog
Aggregated on Sunday December 29, 2013 - Permalink

In case you haven’t seen it, I’m writing a 3-part series about HTTP ETags on the Ibuildings blog. The first two parts have already been published and the third will be out early next year. The literature for using ETags in practice is a bit scattered so I hope this will help centralize it. Part 1: Intro to ETags and Caching Part 2: ETags for Conflict Detection If you prefer …

Continue reading »


Persisting Value Objects in Doctrine

Written by Ross Tuck - Published on Ross Tuck's weblog
Aggregated on Thursday February 27, 2014 - Permalink

I’ve been using more and more Value Objects in my applications over the last year, primarily with Doctrine ORM. Value Objects are an extremely powerful technique and I’ve been impressed with how much they can clean up a codebase. One of the main questions I’ve had when starting with Value Objects is how to persist them with Doctrine. This post attempts to create a reference for all the …

Continue reading »