.comment-link {margin-left:.6em;}
Books & Articles I wrote.

Thursday, June 29, 2006


Entity Expansion

Oftentimes when loading an entity, say an Employee entity, you have a set of contructors which either take an ID for an object to populate or a set of values to poopulate a new Employee.

In many cases you populate part of the object rather than the entire object at this point, avoiding certain fields which may incur some performance penalties (perhaps you have Manager as a field, but know that a call to some separate "Organization" web service is required to get this - you wouldn't want it to happen for every object constructed). On top of this you may have lists which are part of the Employee (e.g. CoursesAttended) which also require more work than is typical.

Of course you can do null checks or have a simple boolean to indicate when a field has been set, but sometimes it is quite useful to have a blanket set of fields updates for a given state. In my case i call this entity expansion, which has 4 enumerated levels (but can be easily extended):

ID - set the ID and do nothing else
Basic - load the basic data
Detail - load detailed information
All - load the entire object (useful in serialization)

I'm sure there are many techniques for this kind of this and you could create a whole host of levels to determine what has been loaded, but find this has worked quite wll in practice and i can easily get the more course-grained "by field" if i wish.

This page is powered by Blogger. Isn't yours?

Weblog Commenting and Trackback by HaloScan.com