Tuesday, January 03, 2012

Welcome to 2012! Granular Programming.

First of all, I wish a happy and prosperous new year to all readers. Here's hoping that 2012 will be far less "interesting" than 2011 was. I guess we can only hope?

So, today's topic is "granular programming" which is a term that does exist at the moment but which I believe is the term that is underused in the context of modern software architectures.  For some time now, I have been using a technique which I like to call granular programming in which metadata and declarative programming techniques allow the construction of a working architecture from objects that may not seem to be related to one another at first.

A prime example of this is something that you may be aware of may not use in your day to day work simply because it's built into the .net framework, and has been since day one and that functions very well on its own, most of the time with no intervention whatsoever from you.  I'm speaking of the type converter system that in .net enables conversion of some binary value such as integers or floats to a string of characters suitable for editing in a TextBox and back again from a string of characters to a binary value.  Types in .net are often associated with the type converter specifically designed for them at a very low level.  Often, in the framework code itself, the association of a type converter with some low level type has been made in advance by Microsoft.

When a type converter is needed by the system it will be loaded, used and then discarded automatically in response to a specific need.  In code, we can specify which typeconverter is required using the attribute designed for that purpose.  In WPF, we can specify a static, or dynamic, resource in XAML creates an instance of our "helper class" which is then used by the rest of the code.  A great example of this in WPF would be a value converter.

This type of "on-demand" instantiation of helper classes is something that I use in my own code more and more.  One interesting aspect of this principle if that its possible to create applications that can be reconfigured and extended without recompiling the application itself.

I will come back to this subject in the near future up in the meantime, if you have any ideas or comments about this subject please feel free to voice them here.

No comments: