2D Head with a clock as an eyeball.
 Friday, June 01, 2007

1280x1024
1280x960

Ok, this counts as the very first desktop published here on Nervoustych! This image was inspired by a recent trip to CodeCampOz in Wagga Wagga. Jason and I were lucky enough to receive funding from work to join the wonderful group of developers there in April this year.

I do hope this image can say more about the Hay Plain than I can.

If you want this image in a different resolution just let me know and I'll make it available here. Can do double and triple monitor renders if you so desire.


Filed under:  | 
 Thursday, May 31, 2007

A good friend of mine, and work colleague Jason Stangroome alerted me to the fact that JetBrains ReSharper 3.0 Beta has recently started. Possibly one of the biggest steps forward is its complete VB support. In the past VB support was limited to very few features. There is now a serious alternative to Refactor Pro! for VB addicts. Other things of note include:

I currently use MZ-Tools for code templating at the moment, its a great set of odds and ends to help you develop in Visual Studio, and the templating functionality is quite useful. The best part is that its dirt cheap. I'm also working on a better snippet interface for Visual Studio, which I'll brag more about when there is somethig to show.

For VB projects I have Refactor installed, which is an absolute boon, however I have tried many a time to install CodeRush trials to give it whirl, and have been left with nothing but frustration.

ReSharper is definitely worth owning, having used 2.0 and 2.5 for fleeting trial periods, I'm already a big fan. I havent been able to justify the cost, since most of the present work I do is in VB. Now that 3.0 is touting VB support, that just became the justification I needed.

Can you tell I'm excited? Im looking forward to getting hooked on this tool, apparently its as addictive as crack, just better for your health.


Filed under:  | 
 Wednesday, May 30, 2007

About a year ago, while designing a few windows forms that pulled in data from typed datasets, I came across a rather annoying forms designer issue that was a little obscure to solve. Lately some other members of the team have been confronted with the same issue.

When attempting to change a data property in the Properties window for some components, for instance the DataSource or DataMember properties. The following message pops up in a message box without any further information:   "Object reference not set to an instance of an object."

The solution is quite simple, by opening the 'Show Data Sources' window you are presented with a list of potential data sources to create bound controls from. It just so happens that this list will, on occasion, show an old data source that is no longer available. Luckily for us these 'dead' sources are easily identifiable by their icon (a small red cross from memory), and you can delete them. Doing so will correct the issue immediately.

This is the point where it starts making a little more sense I guess; the properties window uses an editor control to display a list of components in your project that can be bound to. This editor must use a similar method of discovery as the show data sources view, but its handling of null references during the enumeration of child objects obviously is less than sound.

Incidentally, if you are writing controls that need to be bound to data from something like a BindingSource, using the following pattern will allow your control to appear like other framework controls:

using System.ComponentModel;

private object _DataSource;

[AttributeProvider(typeof(IListSource))]
[Category("Data")]
[RefreshProperties(RefreshProperties.Repaint)]
public object DataSource

   get { return _DataSource; } 
   set { _DataSource = value; }
}

System.ComponentModel.AttributeProviderAttribute is the attribute which tells the property grid to use its IListSource editor. The RefreshPropertiesAttribute attribute tells property editors how to refresh other properties when the value of the marked property changes. The CategoryAttribute simply positions the property in the properties grid to the desired category, when the property grid is in category view.


Filed under:  | 
 Tuesday, May 22, 2007

I have recently been tasked a data conversion that requires me to convert from SQL Data into XML, via a schema (not my design), the resultant XML data going to a BLOB table. Don’t ask.

I battled with a number of options but finally settled on a two step process. I'm using XSLT for the bulk of the work, with a sprinkling of VB to take care of some stuff that needed to use some existing .NET libraries of ours.

 Like most developers I'm often looking for the tool that will speed up my development process and reduce the amount of code I have to write. So I tried using Altova's latest offering in the MapForce range to handle the mapping between the two schemas. I figured this should be a breeze, infer a schema from my existing data (with a few tweaks here and there of course), visually map the old structure to the new, and a wonderfully quick XSLT is born to do my grunt work.

Ooh boy was I wrong....

 So what if the old table I was converting had over 250 poorly named columns? So what if the schema it was mapping to was a 1500 line, 100 type monolith? Did I mention it wasn’t my design?

Even taking these depressing facts into consideration the code MapForce produces is nothing short of abysmal. Every single mapping, regardless of the maxOccurs setting for the type in the schema, gets a for-each tag. I much prefer to use templates for the sake of extensibility, readability & modularity etc. Much like a procedural programmer likes subroutines.

However there is another reason for-each irks me, and here is a snippet of the auto-gen to demonstrate:

<xsl:param name="ForwardSlash" select="'/'"/>

<TitleRef>

       <xsl:for-each select="titleref">

              <xsl:variable name="Vvar24_titleref" select="."/>

              <xsl:variable name="Vvar25_INPUT" select="$ForwardSlash"/>

              <xsl:variable name="Vvar26_RESULTOF_substringbefore" select="substring-before($Vvar24_titleref, $Vvar25_INPUT)"/>

              <TitleVolume>

                     <xsl:value-of select="$Vvar26_RESULTOF_substringbefore"/>

              </TitleVolume>

       </xsl:for-each>

       <xsl:for-each select="titleref">

              <xsl:variable name="Vvar28_titleref" select="."/>

              <xsl:variable name="Vvar29_INPUT" select="$ForwardSlash"/>

              <xsl:variable name="Vvar30_RESULTOF_substringafter" select="substring-after($Vvar28_titleref, $Vvar29_INPUT)"/>

              <TitleFolio>

                     <xsl:value-of select="$Vvar30_RESULTOF_substringafter"/>

              </TitleFolio>

       </xsl:for-each>

</TitleRef>

MapForce just gets it all wrong. There will always be a TitleRef tag in the resultant XML, regardless of whether or not the transform encounters the titleref element in the source document. The duplicate for-each tags are partly because I asked something weird of the designer. “Give me the substring before a slash and put it here, and then give me the substring after the slash and put it there”. However I never intended for this monstrosity to occur. All of this pain could have been avoided with the following XSLT:

<xsl:template match="titleref">

       <TitleRef>

              <TitleVolume>

                     <xsl:value-of select="substring-before(., '/')"/>

              </TitleVolume>

              <TitleFolio>

                     <xsl:value-of select="substring-after(., '/')"/>

              </TitleFolio>

       </TitleRef>

</xsl:template>

Which is what I had in mind when I was visually designing it in the first place. I guess WYSIWYM is what I really want out of a designer these days.

MapForce is actually quite a nice tool for visually mapping and allows you to map between many different types of data source, using a good variety of modern programming languages (C#, XSLT 2.0) to do so. It exposes a good set of functions for you to use in the process with a neat way of visually representing them.

The Big Problem™ is that while the editor will let you visually design your transform, apparently providing two way communications between designer and transform editor was too hard. That is to say, thou canst see the gen’d code but thou canst edit the gen’d code.

My conclusion is that MapForce is your classic I-don't-want-to-know-what’s-under-the-hood kind of auto-gen tool. I ended up dumping the XSLT into VS2005 and used their excellent XSLT editor to finish off. The new improvements to the XSLT interface have made me migrate back home to Visual Studio.

So……Like most developers, I find myself disenchanted with the extremely poor code that auto-gen code tools espouse. I guess it keeps monkeys like me in a job though.


Filed under:  | 
 Sunday, May 20, 2007

Welcome to my little corner of the web,

What you will find here is my creative side, a triptych of coding, music and 3D design. As you might of guessed, I use the word creative in a broad sense. I work in software development, and play guitar in a band, and in my spare time enjoy drawing and creating 3D models and landscapes on my PC.

You can expect to see posts on my current pursuits in the programming world, as well as examples of my 3D designs and music. Please feel free to use my creations, as long as you agree to the conditions of a creative commons attribution-sharealike license. I like to think of it as paying it forward.

So thankyou for visiting, I do hope you find something here of value.

JB


Filed under:  |  | 
© Copyright 2008 Jim Burger