April 2006 - Posts

Code Camp Oz 2006 Review Part 1

Last weekend I attended the excellent Code Camp Oz 2006 at Charles Sturt University in Wagga Wagga, New South Wales.

What is a Code Camp? Well it's not deep training in .NET, and it's not a learning course for VB or C#. It is a no-cost, tightly-packed, two-day-long discussion of broad content for developers, split into about 50% upcoming technologies and 50% current topics. Topics covered in Code Camp Oz 2006 ranged from WPF (Windows Presentation Framework, formerly known as "Avalon") and WF (Windows Workflow Foundation), to the Compact Framework, SQL Server and Team System. The presenters were local experts from the Australian developer community. Importantly, the sessions were highly practical, generally avoiding market-speak and focussing on code. This, in my book, is A Good Thing.

According to the statistics, this year's Code Camp was a little smaller than last year's. I believe that this could be caused in part by the fact that last year, Code Camp focussed on the two major yet-to-be-released technologies of SQL Server 2005 and Visual Studio 2005 - and everyone wanted to get a look at these and possibly many people didn't have the time or gear to set up beta's or previews for themselves. This year, there seemed to be a general feeling that the upcoming (previously Vista-timeframe) technologies of "Avalon", "Indigo" and WinFS would be released only when they were ready, and full integration with Visual Studio wouldn't come until the next version of VS (2010?).

I enjoyed meeting up with Nirav again, who I first met last year, and talking the inevitable "shop". Nirav is consulting on a large Delphi project but had studied VB in a prior life so he and I had lots to chat about. In among the many people I talked to, I also met a bloke called Stuart who I mistook for someone else (not the first person I embarassed myself in front of). I enjoyed the social aspects of Code Camp this year too, like the two dinners where I got to meet lots of interesting people.

Stay tuned for my Code Camp Oz Review Part 2 where I talk about the presentations themselves.

Technorati tags: code camp oz, code camp

Getting the SQL Server from an IdeaBlade DevForce Express AppHelper Assembly

As mentioned previously, I have been using IdeaBlade DevForce Express to generate a business object layer for a .NET 2.0 project.

For this project, I needed a way I could determine the SQL Server that the DevForce business objects would connect to, without necessarily creating a business object and testing the connection properties. IdeaBlade DevForce creates a helper assembly with an embedded XML document called "IdeaBlade.ibconfig" containing the SQLOLEDB connection string for data access, and so I needed a way to:

  1. load the helper assembly
  2. read the XML document from the assembly's embedded resources
  3. find the connection string
  4. get the server name from the connection string

Step 1: Before reading the resource, I had to create an Assembly object using System.Reflection.Assembly.Load (all the code here is VB.NET for .NET 2.0):

Dim helperassembly As System.Reflection.Assembly = System.Reflection.Assembly.Load("AppHelper")

This loads the assembly from the current directory - you must check that the returned "helperassembly" is not Nothing.

Step 2: The next part was to read the embedded resource (the "IdeaBlade.ibconfig" XML file) from this assembly. This was done with code based on Daniel McGivern's sample at http://mcgiv.com/blog/2005/06/16/Reading+Assembly+Embedded+Resource+Files++GetManifestResourceStream.aspx, which is separated out into a function:

    Public Function GetResourceTextFromAssembly(ByRef assembly As System.Reflection.Assembly, ByVal name As String) As String

        ' set up a stream for the XML resource
        Using sm As System.IO.Stream = assembly.GetManifestResourceStream(name)
            ' if we got a resource
            If sm IsNot Nothing Then
                ' get resource as text
                Using sr As System.IO.StreamReader = New System.IO.StreamReader(sm)
                    Return sr.ReadToEnd()
                End Using
            Else
                ' we could not find the resource specified by "name"
                Return Nothing
            End If
        End Using

    End Function

You need to call this function to get the XML as a string, passing the previously-created helperassembly Assembly and the name of the resource to retrieve, which is "AppHelper.IdeaBlade.ibconfig".

Steps 3 & 4: I won't post an example of the "IdeaBlade.ibconfig" XML, but the important part is that the connection string is stored in an XML element and could probably be retrieved using XPATH and tricky Mid() or Substring() calls. I chose to use a regular expression, thinking that I would look for a string like "Data Source=" and get whatever was after the equals sign.

Aside: Regular expressions are probably the closest thing to alchemy in modern times. I felt like I was muttering incoherent incantations as I inserted question marks, dollar signs and square brackets to make my regex spell work.

With the help of the excellent Regex .NET Tester tool, and MSDN documentation, I worked out that a regex that does the job is something like:

(?<=[D|d]ata [S|s]ource=)(\w+)

This looks for the string "Data Source=" but does not match it, then matches everything to the next word boundary (which includes not matching a trailing semi-colon, if there is one).

Big disclaimer: this code worked for me. I hope it helps someone else, but I make no guarantees. I have not tested it with SQL Server instances. Nor have I tested it with multiple connection strings. Or even connection strings which don't have a "Data Source" section.

And that's how you get the SQL Server from an IdeaBlade DevForce Express "AppHelper" assembly.

Technorati tags: ideablade, ORM, connection string

My Mug Shot as at April 2006

This is a current picture of me - if you are going to Code Camp Oz in about a week's time and recognise me, please come up and say hello :-)

Lucky SQLDownUnder Show #13

I was listening to Greg Low's podcast SQLDownUnder show 13 with Bill Graziano, and my ears pricked up when Greg made the comment that most of the consulting he does is on improving performance, and posed this as a question back to Bill as to why...actually, I became interested because Greg mentioned that developer knowledge could be to blame - that's me :-)

The first part of Bill's answer, and the part that stood out, was:

"...[I]t's easy to grow data at a rate that we never could before. Back in the 80's...it was just so much harder to generate data with people typing it in - and now you've got systems that generate data for other systems..."

Bill and Greg followed this up by commenting that database size is an issue also as historical data is being saved, because of availability of disk space. Greg even shared the example of a database that collected electricity meter information every 15 minutes for every meter in the state - where previously they received one reading per meter per quarter!

Bill and Greg both have some helpful hints for developers (like me) working with SQL Server to improve performance, and the show is worth the listen. The whole angle of "performance tips for developers" made sense when Bill mentioned he's presenting at PASS SQL Conference on "What I wish developers knew about SQL Server".

As I listened, I realised I was clearly a developer and not a DBA e.g. I am concerned about my application, and not so much the SQL Server! Still a lot to learn...

Technorati tags: sql server, sql server performance, Greg Low, Bill Graziano

Data Entry Screen Considerations

SQL Server MVP and Oz Regional Director Greg Low posted a while back on "What Makes A Good Data Entry App" (I'm just catching up on some old, bookmarked, reading). He has a checklist of important considerations for designers, which is well worth following.

I found out the hard way that Greg's remarks on font sizes are relevant - an application I'm designing used the default font and size which would be fine for me, but after demo'ing the application for a user I observed that for this particular user, my screens seemed unnecessarily compact and small. Changing the font size and opening up the layout made the application look much better.

On the font size issue - a couple of things I've found helpful (while not directly related to Greg's points) are that Visual Studio 2005 & .NET 2.0 (Windows Forms) make it easier to have screens that scale well with the AutoScaleMode property on forms, AutoEllipsis on buttons, checkboxes and labels, and the new TableLayoutPanel control (which I haven't played with much).

Greg also points out that errors should be handled in a non-intrusive (e.g. non-modal) manner. I have come around to using the ErrorProvider control for marking fields that need further attention and setting focus back to the first control with errors.

One thing I think could improve the whole data-entry screen "culture" is for Windows Forms to take a bit more notice of web-based screens hosted in a modern browser. I think that over recent years, and now that JavaScript works (e.g. AJAX), lots of smart people have put time and thought into making web-based data entry screens more usable. In my mind this extends even to including simple, Scriptaculous-style animations where appropriate (currently next to impossible with Windows Forms).

Technorati tags: windows forms, .NET development, scriptaculous