In my free time I have been working on a total refactor of my framework the Crossley Framework/Library (XFL as I like to call it). It is kind of fun to revisit all my past decisions, sometimes made in candy store fashion. You know, like when a kid is in a candy store and cant chose a candy bar. I was once told that if I picked one I could try a different one next time. In this vein I make quick decisions when needed. Although there are some cases where I don’t want to have to deal with the effects of some bad implementation, that is what is so great about refactor time. The primary goal of this round of refactoring is to simplify and focus implementation. I have to admit that I was influenced by some ideas that I don’t agree with any more. That and time constraints always result in some bad candy.
One of the situations I have had to address in the past is that of a standard data structure that can be passed via Ajax calls. I wanted to be able to have a standard way to include messages and errors with data being sent to the client, and maybe even include a swatch of markup. To solve this problem, I came up with the Mancunian Object (named for the Crossley Mancunian). This started as a standard structure and evolved into a set of classes in PHP and JS.
As is implied by the name, shared with a multi-layered bus, the structure neatly communicates key value pairs and strings containing error messages and markup. Because of this the server and client can be set to react to these objects in a uniform fashion. It is a simple mechanism that is useful when you are building one page web applications.