Proxies
Tuesday, October 8th, 2002Dynamic Proxies are kind of fun. I’ve been thinking a lot recently on business objects and how they’re bbasically pretty easy things that shouldn’t take much work.
It seems a lot of people agree with me as the Java world is full of Object to Relational mappers that attempt to do lots of stunning things. So much of my thoughts must be repeats of what is already out there.
First off though, I was thinking about Random objects, cued by a colleague.A RandomBean is very nice. Sitting on top of a random structure it allows a random anything to be created [ideal world] which is perfect for stubbing code and some unit tests. So my first business object playing in this period of thinking was a RandomBean structure. This works nicely.
Previously I had decided that all business objects should enforce the Null pattern. So absolutely NO NullPointerExceptions in the system. To do this I was code generating, but although I like writing code generators, I’m not convinced they are great for a project [though they are great for a coder wanting to impress].
Much nicer however to have this automatic, so dynamic proxies for the implementations of the business objects. Maybe a nice generator so I don’t have to code the interfaces by hand. This appears to be working nicely. Although I’ve not tackled more interesting things, like indexed and bound properties. Still, shouldn’t be hard.
So the next step is to add a NullProxy thingymebob. Hook that into the Impl so Null pattern is enforced. So, when I get around to dotting t’s etc [ie implementation], there will be a nice structure for taking an Interface and getting a library to do all the work.
Next? Next I’ve been thinking about object relational. Yeah yeah, everyone does this. But I do sit and think, it would be nice to plug an SQL in somewhere, then map column names in the result set to property names in an interface. It’s almost like bean-generics. I write my type with its properties, and then there is a whole series of generic implementations which use proxies to merge type [ie design] and functionality together into an easy to put together set of bits.
It sounds fun anyways. But bound to already be out there somewhere.
