20 Aug 2010

It's Dev4Dev's time again!

My favourite gathering of developers happens 2 or 3 times a year, it’s called Dev4Devs. This is a free event which Microsoft runs, where ANYONE can present a topic but they only have 20min! This means that in a morning you see 7 topics and rather than getting swamped in all the details you dive directly to the really important parts.

The topic list is below, and there is some exciting topics there and even some non-MS technology is covered too!

I am also really glad that the entire ATC team at BB&D, which is the team I work in, is presenting – they are highlighted in the list below!

The next one comes on the 4th September 2010 and it occurs at Microsoft’s offices in Johannesburg and you can register at https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032456806&Culture=en-ZA

Session List for Dev4Devs

Windows Phone 7 - Getting Started

A high level introduction to getting started with Windows Phone 7 development including: where to begin, options for developers, thinking about design and a demonstration application.

Presenter: Johannes van Schalkwyk

Making MVVM easy

Starting with WPF, Silverlight or WP7? Heard of MVVM but think it’s WAY too complex for your simple application? Join me for a crash course using the easiest MVVM framework available… Caliburn.Micro!
Presenter: Rudi Grobler (ATC Team Member)

Why you should care about Google Closure

Closure is a modularised set of JavaScript libraries that can assist you in building rich internet applications.

It's been battle-tested by Google on sites like: Gmail, Google Docs and Google Maps.

Attend this short intro to get an understanding of how important these libraries are and why you should consider using them in your next big internet app.

Presenter: Simon Stewart

Introducing NHibernate 3

The daddy of .NET ORM is back with a new release, in this session you'll see a few of the newest features - such as a full IQueryable LINQ provider - that makes NHibernate 3 the best release yet!
Presenter: Kevin McKelvin

Branding SharePoint 2010 with MasterPages, Layouts and CSS

One of the largest limitations of WSS3.0 and MOSS2007 is the ability to brand SharePoint without intricate knowledge of the platform and in some cases breaking a few rules and modifying out of the box system files to get the desired look and feel. Come and see how the theming engine in SharePoint 2010 together with CSS, Master Pages and Layouts can be used to brand your SharePoint site using the amazing new SharePoint Designer 2010.
Presenter: Brent Samodien

Unit Testing - Code Coverage & Mocking

In this presentation William will demonstrate how code coverage tools help measure the effectiveness of your unit tests.  He will also show how Mocking tools can help to add value to your unit tests and ensure that all edge-case logic is properly checked.
Presenter: William Brander (ATC Team Member)

Getting ready for Windows Azure development

Heard about the cloud? Excited about the possibilities? In this session we have a 1000-mile introduction to Microsoft’s operating system for the cloud, Windows Azure, how it compares to the other cloud offerings that are out there and how to get your hands dirty with the skill-up process. Endless possibilities + new tech = fun stuff.
Presenter: Ryno Rijnsburger

An introduction to Mercurial Source Control

Want a quick introduction into a Distributed Version Control System (DVCS)? Meet Mercurial it is a cross-platform, fast, lightweight source control management system designed for easy and efficient handling of distributed projects.
Presenter: Zayd Kara (ATC Team Member)

Making money with Coded UI

Coded UI is a brand new feature of Visual Studio 2010 which enables you to quickly build automated user interface tests for your application and run them as if they were unit tests. In the talk we will look at how Coded UI can change your life, one UI at a time!
Presenter: ME! (ATC Team Member)

Hack .Net in 10 Seconds - Why obfuscation is critical

Hacking 101 – I demonstrate how to bypass basic copy protection in an unobfusctaed .Net application through reverse engineering and show how obfuscation adds a layer of protection. I also demonstrate additional techniques for protecting your applications from hacking once they are released in the wild.
Presenter: Mark Pearl

Composite Applications with PRISM

In this session Stephan will demonstrate how to leverage the Composite Application Libraries to create modularized applications for WPF and Silverlight. He will also show you how to do multi-targeted development by sharing lots of code between the web and desktop applications.
Presenter: Stephan Johnson

An Introduction to Pex and Moles

An introduction into Pex and Moles, covering the basics of Mole Types and Mole Stubs and Parameterised Testing.
Presenter: Dave Russell

ASP.NET Dynamic Data

I will briefly introduce ASP.NET Dynamic Data by showing how to build a complete data maintenance web application with almost zero code.

Moving on, I will demonstrate some standard ways of customising a Dynamic Data application, and some more advanced non-standard customisation techniques. I will finish off by illustrating how Dynamic Data libraries and controls can be leveraged in other applications that don't normally use dynamic data.

Presenter: Brady Kelly


As you probably already surmised, ASP.NET MVC 3 is the next major release of ASP.NET MVC. Join us as we highlight the upcoming features and modifications to this popular framework.
Presenters: Jaco Pretorius and Kobus Brummer

19 Aug 2010

Pulled Apart - Part V: You are a DB server with SQLite

onebit_26Note: This is part of a series, you can find the rest of the parts in the series index.

One of the design decisions for Pull, is that it should just run without the need for an install. This requirement means that everything it needs to run should be available all the time and this brought an interesting problem to my design. The issue was that I needed a database to store all the info Pull uses (podcasts, episodes etc…) but I couldn’t require people to install SQL Server Express or PostgreSQL.

The solution was to use a file based database called SQLite, which requires just a few dll files to provide all the database functionality I would expect to my application to use but without the need for a database server. As this is a .NET application I used one of the wrappers for .NET called System.Data.SQLite. Usage with System.Data.SQLite can be via ADO.NET like code or via the Entity Framework.

I initially used EF for my development, but I found a mass of issues due to the assumptions that EF makes about when to open/close connections. These assumptions make sense when I have a DB server, but when I have a file which will be called from multiple threads those assumptions come back to bite and caused me no end of pain.

What I ended up doing to solve it was to build my own ORM which made use of reflection to handle mapping to classes, ala EF, but used a static instance and was very eager to close the connection to the file. These changes solved major issues with stability caused by EF while still providing a decent developer experience.


Mapping of my classes to the database is done using a simple attribute which has a name and primary key indicator. For example the log class looks like the following. Note that I use the same attribute for columns and tables as I assume Class=Table and Property=Column. In the following all the properties names match the DB column names, but this is not a requirement.

[DataStore(Name = "Log")]
internal class Log
    [DataStore(Name = "PK", PrimaryKey = true)]
    public Guid PK { get; set; }
    [DataStore(Name = "Source")]
    public string Source { get; set; }
    [DataStore(Name = "Occured")]
    public DateTime Occured { get; set; }
    [DataStore(Name = "StackTrace")]
    public string StackTrace { get; set; }

    [DataStore(Name = "Message")]
    public string Message { get; set; }

Using that information, I can take a object and using reflection build up the SQL needed. An example of this is how I create the update command:

private static SQLiteCommand ConvertToUpdateCommand<T>(T item)
    SQLiteCommand command = new SQLiteCommand();
    string insertCommandText = string.Format(CultureInfo.CurrentCulture, "UPDATE [{0}] SET ", ((DataStoreAttribute)typeof(T).GetCustomAttributes(typeof(DataStoreAttribute), false)[0]).Name);
    int parameterCounter = 0;

    object PKValue = null;
    string PKColumn = string.Empty;

    GetAttributedProperties(typeof(T), (property, attribute) =>
        if (!attribute.PrimaryKey)
            insertCommandText += string.Format(CultureInfo.CurrentCulture, "[{0}]=@A{1}, ", attribute.Name, parameterCounter);
            command.Parameters.AddWithValue(string.Format(CultureInfo.CurrentCulture, "A{0}", parameterCounter), property.GetValue(item, null));
            PKValue = property.GetValue(item, null);
            PKColumn = attribute.Name;

    insertCommandText = insertCommandText.Remove(insertCommandText.Length - 2);
    insertCommandText += string.Format(CultureInfo.CurrentCulture, " WHERE [{0}]=@PK", PKColumn);
    command.Parameters.AddWithValue("PK", PKValue);
    command.CommandText = insertCommandText;

    return command;

Final Thoughts

I have been very happy with SQLite as a database, but the learning curve has been tough for someone coming from a database server history. Once I understood the limitations and differences to DB servers it has been a great experience with SQLite.

I’ve been very happy with my ORM as it has made the development very easy working with proper objects and really hiding all the DB functionality away. There are some performance issues in the ORM which I have not solved and I am not feeling a major rush to solve either because the sizes of data in Pull are fairly light to start with. Examples of those performance issues is

  • I have no way to batch commands in one transaction. So for inserting podcast episodes, for each episode I create a new command, a new transaction, open the DB, run command, close DB and transaction. What I should have is a way to create a bunch of commands and then run them all using one transaction and one open/close of the DB.
  • Updating updates every field in the object, regardless if it has changed. This is because I have no object tracking implemented to figure this out.

Despite these the system still runs really well and overall I am happy with the choice of DB.

08 Jul 2010

Presentation Dump - Mid 2010: VS2010, NDepend, RESTful Design, SSIS, EntLib 5, .NET Reflection, AppFabric, BDD, Sikuli & Redmine

The past 6 months have been hectic from a presentation perspective for me, with 20 presentations and classes given this year so far. So instead of a single dump of presentations at the end of the year, as I did last year, I am doing a mid-year dump.

What is new in Visual Studio 2010

This presentation is the one I have given many times this year. It originally started as 10 on 10, which looked at 10 features in 20min for Dev4Dev’s last year. It then evolved into 12 on 10, which added two more features, still in 20min. It then evolved into ?? on 10 for 6 degrees of code where it became an hour and half presentation. It is demo heavy and really the slides are the very basics – the important is hidden slides and notes for the demos.


The tool that keeps on giving! For people working with taking over customer sites, reviewing code or anything else where you need to deal with other peoples code this tool is a must. This presentation was given to the architecture team at BB&D.

RESTful Design

RESTful design is an evolution of an earlier presentation I did, REST & JSON, which drops the JSON stuff completely and also drops the heavy compare with SOAP/WS* parts which seemed to cause confusion. This revised presentation covers just REST and looks at it much more practically by covering the required HTTP knowledge and patterns for designing RESTful services.

SQL Server Integration Services

Another upgrade in 2010 of an earlier presentation which not only cleans up some aspects but also goes into a lot more detail.

Enterprise Library

“The presentation that never was”, often I will spend time researching a technology or trend and preparing the presentation to come to the conclusion that it is just not worth the time of the attendee’s. Enterprise Library 5 is one of those, as the presentation covered what is new in it, and that is not very much.

.NET Reflection

This one is actually one from last year, but I had problems getting it onto SlideShare so it is only showing up now.

Windows Server AppFabric

AppFabric, the local one – not the Azure one, was a great presentation I did for the BB&D architecture team. This is not the original presentation – it has been edited to remove customer info as a lot of analogies between a project BB&D did and AppFabric was in it (cause who hasn’t built a system similar to AppFabric).


One of the presentations I spent the most time on this year, and one of the most exciting presentations. It really is a great methodology and I would love to see it used more.


Another presentation which did not make the cut to actually be presented. It is an interesting project, but of limited scope and when compared to the Coded UI from Visual Studio 2010 it is really far behind.


Redmine is a bug tracking system, and being it’s not TFS may surprise you that an ALM MVP would do training on it. However for me to do training meant I head to learn it, which means I know the ALM landscape better and can point out which is better or not without uneducated bias (btw it still is TFS :)). This training was aimed not at developers but at call centre/power user people who would log initial bugs to then be managed in the system – so it was more of a ticketing system than a bug system in the end.

08 May 2009

My Presentation @ Dev4Devs

If you are attending Dev4Devs on Saturday (or are here after the event) and you are looking for a copy of the slides and code you can get them below! If are looking for the ADO.NET Data Services cheat sheet I mentioned then you need to go here.


The code here is also different from what I presented in the following ways:

  • There is a timer control in it - so if you add items to the DB while on the site, it updates and shows those changes within 5 seconds.
  • The layout is slightly bigger (bigger header) and has buttons (to make it look like an email client) - these were removed because it doesn’t work at 1024x768 (aka the projector resolution). So they back in their graphical beauty.
  • There is a feed button which links to a ATOM feed for the last 10 emails - something I mentioned you could do, well now you can see it.
  • There is a database creation script, but no data. You need to create your own data.
Slide Show
16 Mar 2009

ADO.NET Data Services - Weird Error

Working on a project which uses ADO.NET data services for a small part of it. I put the ADO.NET Data Services portion together (add the files, put the EF data model together, link it up etc…) on my machine (Windows 2008 Server, SQL 2008, VS 2008) and it all worked great! Checked into source control and then went about doing something else, ignorant of the coming problem.

Then the developer who would actually consume it (we are consuming it in C# using LINQ) came to me saying that nothing worked :( All we get is the generic ADO.NET Data Services error: “An error occurred while processing this request”. We removed the where clauses and everything worked perfectly, which hinted to me the LINQ/EF expression tree was borking out somewhere. So we went to the EF data model, told it to update and it did a change under the surface and everything worked again?!


I love TFS because it allowed me to compare my version and the updated one easily and their was one tiny change (literally 1 byte!) in the edmx file (not the .cs backing file, the edmx file itself). Turns out that in dev they are using SQL Server 2005 and I built the model with SQL Server 2008 - now note there is ZERO 2008 special features in use, but it seems that the EF expression tree doesn’t care and try’s to use some SQL 2008 magic cause it thinks it is SQL 2008. This is controlled by the ProviderManifestToken attribute! Changing that to 2005 (which is what the update did automatically for me) solved the problem!


24 Nov 2008

SQL BI Boot Camp - Day 2

Ah, day 2 has arrived so I got up at 6 to get ready and watch the email trickle down (Emerald Casino appears to only have GPRS for Vodacom) which didn’t finish in the end. Unfortunately this post will not be as informative as the previous two, because what I was doing was taking notes on the machine I was working on and about an hour before the end of the day there was a power failure and I was not able to retrieve my notes :( So not only did we leave early, it was meant to be a short day to begin with… nice for a Friday to avoid traffic and get home early.

What stood out for me for that day was working with PerformancePoint which is a business user tool to build dashboards, KPI’s and scorecards. It was impressive at how easy it was to work with it, especially considering that in the background it’s creating cubes, writing MDX etc… This is the way this is meant to be. However it is a BUSINESS USER tool, so much so that Kevin (the presenter from IS Partners) was telling how they hired four CA’s in the last month and trained them to use PerformancePoint rather than training “BI people” to understand business. From speaking to some of the Microsoft people who have used it, the installation of PerformancePoint though is exceptionally tough and I was disappointed that it was not even touched on :(

Anyway without notes it’s hard to write long posts without possibly making huge mistakes, so I will leave it there for what was covered.

As an event it delivered on the initial point of being a level 200 course and helping understand the concepts and helping business users. The problems with labs and manual are understandable (these things happen) but considering you are paying for this and this is a MICROSOFT event it definitely should’ve been more professional than it felt. I would recommend this course to analysts and business users but not to development or serious BI users.

24 Nov 2008

Layout data horizontally in SRS

I recently had a question about layout in reporting services. Basically if you use a table you get a vertical layout, like this:

First Name

Last Name








But what if you want to go horizontally? Sure there could be UI issues because the report will get wider and wider with more data getting put in and it could influence the quality of export or printing but in a special scenario it would be very useful. Unfortunately the tablix control (Table + Matrix + List in 2008. See my post on what’s new for more info) does offer this natively :( But using a trick you can get around it. First you need a tablix in matrix format (i.e. drag a matrix onto the form), and then add a new column header for each column, but rather than putting a header text in there you put the data in there. You ignore the rows and data cells (in fact you can hide them by setting the hidden property to true).


And the output is a horizontal layout of data: