Programming I've been up to

It’s been a while since I discussed anything programming related.  Believe it or not, I have been doing some tinkering.  First, let me talka little about what I’ve been working at on and off at work going back a few months.  If that doesn’t drag on too long, maybe I can talk about some cool non-work stuff I’ve been playing with.

One of my team was working on a side project that had a somewhat dynamic data aspect to it.  What I mean is depending on a certain type selection made by the user, there was some data for that selection that wasn’t needed for other selections.  This was a fairly large aspect of the application.  He had a data model worked out on how to set up for these special types, and getting them to and from the database.  Displaying it was the problem.

Very simplistically making this more concrete, let’s say that if the user picked selection A, he’d have to supply fields 1, 2, 3.  If selection B was picked, fields 4, 5, 6 would need supplied.  Given that future selections may need to be added that required other data, a flat model where each selection would just have all the fields didn’t make sense.  While each selection had a number static fields common across the selections, each selection had it’s own distinct data.

Initially he was thinking he was going to have to create a separate screen for each type of selection or at the least a separate panel unique to each selection.  I told him he shouldn’t have to do that.  We could make a special panel that would dynamically display the data depending on what was needed.  So I set about tinkering with it in my spare time.

This whole app is supposed to be a tempory hack to get the users through the next couple years.  So I wouldn’t say my solution is extreme enterprise quality.  I didn’t take the time to figure out how to get my controls binding to a data structure.  We’ve got some pretty slick (when it’s not causing troubles) binding in our Eclipse RCP app that automagically binds back and forth between controls and a data obect.  I haven’t dug into exactly how that works yet, but it’s on my list of todos.

I created two controls for displaying this dynamic unknown data: a dynamic grid table and a dynamic composite.  Both would add controls (Text, Combo, etc) based on what type of data was needed.  This was all backed by a list of property objects that described each required field, such things as the data type, value object, field title to display, etc.  The table would show a list of two columns, one for title and one for a control to hold the value.  The composite (which was used and subsequently more work put into) would layout a set of labels and controls as defined by the backing list.

The underlying database model stores everything as string so I added some convenience methods to load and extract the data from the underlying list as strings.  All in all it works pretty well and saved a lot of time that would have been stuck in making special panels for each selection type.  Not to mention the time that will be saved when a user requests some additional field to be added to a particular selection or a whole new selection added.  My co-worker made a pretty slick admin panel to handle the building of the dynamic data and additions.

This little side trip helped me learn a lot more about straight SWT.  I really enjoy being a developer of tools for other developers to use.  I have plans to add an easy builder way of creating the underlying list and being able to magically bind to and object.  But, there’s always new priorities so I may not be able to get back to it.  Perhaps I’ll someday find a need for such a thing in my own projects and can create a better version from the experience I’ve gathered.

Well, I didn’t get to the other side project at work that I detoured on involving JPA, so I’ll have to save that for another time.

Advertisements

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: