When Design Patterns Attack
Posted by Ben Jackson Thu, 20 Mar 2008 18:35:22 GMT
I spent the better part of this morning debugging an issue with Blogo which only affected typo users.
The issue was especially severe, as draft posts saved from Blogo were being published by typo without the user's knowledge and without any notification.
It turns out that typo was changed last year to use the State Pattern to determine whether or not to publish posts. This boils down to a set of observers which are notified when setting the `published` or `published_at` flags, and which publishes or queues up the article based on the current time.
However, after looking at the backend code for typo, it's become clear that typo ignores the published flag when posting to the XML-RPC backend, and bases the published status on the `published_at` flag instead.
This is a fundamentally flawed approach, as I outlined in my ticket on the subject three weeks ago (which, even though it included a patch with passing regression tests, has still not received a response as of today).
If I set published to false through the API, I expect my post to not be published. If you're using design patterns, make sure that you don't get distracted by the abstraction to the point where you lose sight of the proper behavior of the system.
