# Friday, 04 April 2008

anug_logo_200x85 My good friend at Scanvaegt Henrik Kristensen has talked about Windows Workflow Foundation ever since I first met him so naturally we had to invite him to give a talk on it for ANUG.  We were fortunately enough that he accepted and even provided a nice cantina for the ANUG boys to use for the duration.

User Group News

The March meeting opened up as usually with myself giving everybody a quick rundown on what's going on with ANUG; mainly focusing on meetings to come. We been fortunately enough to be able to stay ahead of the curb on planning meeting and I'd like it to stay that way so we're planning the next batch of meeting for April, May, June, and we've even got January 2009 booked so stay tuned :)

Future topics include ASP.NET MVC which I'll do a little song and dance about, Windows Communication Foundation which Klaus Hebsgaard has been good enough to agree doing a talk on, and finally a talk on TDD which Mark Seemann agreed to do.

The not so set in stone topics that we'd like to see presentations on include WPF to kind of come full circle on .NET 3.0, Pro Tools where we discuss the various tools and utilities that devs use in the day to day work to get the job done, Subsonic the darling of the ORM world, and a bunch of others topics. We'd like to bring in more open source tools and topics like DotNetNuke and NHibernate so don be shy, please contact me with your ideas.

The meeting marks the second showing of our new format. We noticed that we got quite a good buzz among people for the first break of the evening but not so much so with the second so we decided to break up the main presentation in two pieces to allow people more time to talk with each other and get to know each other. Like the previous time at Systematic it worked out nicely with people clustering around and discussing a number of different subjects. The new format is definitely a keeper.

IMG_2247 IMG_2248

Download my slides

Windows Workflow Foundation w. Henrik Kristensen

The main event of the evening was of course Windows Workflow Foundation a tool that I myself didn't know a lot about. Mostly high level stuff but I definitely see the potential there.

Henrik made a good show case on WF, the rules engine and the workflow engine. He even brought out his LEGO Mindstorms robot the demo how you could do a workflow to actually control it. The little bugger has other ideas though as it cruised along and right over the edge of the table. In spite of the rebellious little robot ("is this how is begins?", he asked  with the killer Mindstorm robot fast approaching) the point was made very clear with the showing.

Pitfalls in WF were highlighted neatly by way of the robot. For example WF has a notion of a parallel activity which at first look might persuade you to think that you get some kind of multi threading for free. Unfortunately the only we get is a kind of pseudo parallelism where the parallel activities are execute in order.

IMG_2258 IMG_2257 IMG_2261

In all Henrik did a great job of highlighting why we should care about WF. Basically every LOB application today has some kind of workflow built in be it by way of statuses, custom state machines, whatever. The rules engine in particular was interesting to me as I've lacked such a thing a number of times in the past. What I've done before is basically forego the better solution for something simpler to implement because I didn't want the hassle of building a rules engine myself. No more, the next time such a need arises I'll definitely have a go at using the WF rules engine. The configurability alone is worth it.

For the workflow engine I noticed an interesting thing which is the fact that inherently it will make you thing in components. Basically a workflow is built from a number of activities which are stand alone tasks that can manipulate the data flow in some manner. Pretty much we're dealing with a components here and the model makes you go into a certain mode where you naturally try to decouple the activities from each making for much better reusability.

Workflow Foundation may not be the sexiest of the four pillars of .NET 3.0 but it does provide some real value to the developer toolbox.

Download Windows Workflow slides by Henrik Kristensen

Scanvaegt International Redux

Like the last time we were fortunate enough to be able to use the Scanvaegt offices Henrik also gave us a rundown of Scanvaegt. We both figured that the audience would have changed a bit so it was safe to to the presentation once more. Last time around he brought a great video of a machine sorting chicken (yes, I know it sounds lame, but you have to see this thing in action :)). This time he brought a different one showing a machine 3D scanning salmon and cutting it in equal sizes in seconds. This time around you can even check it out yourself as Henrik provided me with the video to share with you guys.

Interesting stuff has happened at Scanvaegt since the last time we were there. Last year they'd pretty much just been bought by a competing company by the name Marell. Since then they've worked on sorting out their product lines as a lot of overlap has been going. Among other things this means that Henrik is non associated with their Icelandic development department and he's even had the pleasure of going to Iceland a couple times. He briefly outlined some of the unique challenged in working in a very distributed environment. Interesting stuff for sure.

Download Scanvaegt International slides by Henrik Kristensen

posted on Friday, 04 April 2008 12:39:15 (Romance Daylight Time, UTC+02:00)  #    Comments [2] Trackback
# Thursday, 03 April 2008

glatfore_skilt I'm now officially a statistical anomaly. Only last November I encountered a ghost driver and in my post Could Have Been Me I write about what could have happened if I'd decided to try and take over another car at the very moment the ghost driver came upon me.

Well tonight turned out to be that night. On my way home from Århus I encountered a different ghost driver only this time I was actually in the same lane as the other guy. Luckily I had my wits about me and managed to swerve out of his way.

So please just for a year or so give me break. I really think that I've had to deal with enough ghost drivers for one life time. WTF!

posted on Thursday, 03 April 2008 23:16:00 (Romance Daylight Time, UTC+02:00)  #    Comments [2] Trackback
# Saturday, 15 March 2008

anug_logo_200x85 Saturday 15th marks the date for the first ever code camp held by Aarhus .NET user group. We went with ASP.NET for beginners as the theme building a small blog application with Visual Studio 2008 and ASP.NET 3.5. Due to space constraints we'd set the upper limit for attendees to 12 and I'm happy to report that we had a full house. The skills levels of the attendees varied from people who'd never opened Visual Studio before to people with some knowledge about ASP.NET.

Brian put together a nice program which took the attendees through creating various new features for the blog application like adding comments and membership support for login. To get the attendees coding some of the interesting parts of the application Brian provided a nice starting point for the code camp with a blog application laid out nicely in a Visual Studio solution along with a database. Due to differences in how we usually work with the stuff we encountered some interesting problems with getting the database up and running in SQL Server Express. Turns out that the SQL Server engine is prohibited from accessing user folders on the machine it's running on.

Coaches were in place to help out with questions the attendees might have, Søren Lauritsen who signed up to help at the last minute provided valuable help during the day, as did Brian himself between the short tech briefings, and myself. Every single attendee came well prepared and had all the prerequisites installed before showing for the code camp, thank you all for being so well-prepared.

 

 IMG_2234 IMG_2228 IMG_2235

 

During the day we had nice discussions on various aspects of ASP.NET, .NET in general, and we provided a number of tips and tricks like looking at compiled assemblies with Reflector and taking that a bit further with TestDriven.NET which enables you to simply right-click on a referenced assembly in Visual Studio and open it up in Reflector; no more digging around the file system to find that pesky assembly.

URLRewriting.NET was discussed along with ASP.NET MVC for creating friendly URLs. And I should mention that I'm doing a presentation on ASP.NET MVC in April If you want to know more about that in general. I'll post more information about that meeting once I know more about the particulars. As always the date and time is set so make sure to mark your calendar for April 30th 18:00 if you wish to attend.

Thanks to all who attended the code camp my impressions are of a successful day during which the attendees learned a lot. With that I'll leave you with some more pictures from the day. As you can see people were deeply focused but still very eager to help each other out. Nice work everybody!

Be sure and grab Brian's source code and presentations. Also you can check out all the pictures taken at the meeting.

IMG_2238 IMG_2243 IMG_2241 IMG_2231 IMG_2240 IMG_2237

posted on Saturday, 15 March 2008 12:35:50 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback
# Thursday, 13 March 2008

Commerce-Server-2007-Logo In my mini series about the Commerce Server development experience I did a piece called Magic Strings Galore which describes the general tendency to have all data in the various CS objects accessible via strings. Imagine a product with a rich description. You would access that like a hashtable, e.g. product["RichDescription"]. No way of knowing the return type , no discoverability via intellisense, poor refactoring support. Sure ReSharper takes care of some of that by looking at string literals when doing refactoring but surely there must be a better way to fix this. It turns out there is and I'm going to let you in on the secret :)

In my previous post .NET Framework 3.5 and Microsoft Commerce Server 2007 A Match Made in Heaven I discussed some options for using extension methods to add missing functionality to the built-in Commerce Server classes. Using this method you can augment the existing interface of Commerce Server but it doesn't really provide you with a nice place to put all the domain logic that is bound to turn up eventually. To solve this problem I came out with an automatic mapping layer sitting on top of the Commerce Server Profile System which translates the stock Profile into rich domain entities filling in the gap and giving you that place to put your custom logic and at the same time doing away with all the problem with magic strings that I described above. I call it the ProfileRepository.

The ProfileRepository is not a true object relational mapper in the sense that I'm not really converting from the relational model. Luckily all that is taken care of for me by the profile system of Commerce Server so I pretty much just have to provide the type safe abstraction.

Requirements

ProfileRepository My requirements for the ProfileRepository is the following. I want the developer using the framework to easily be able to map an entity, say User, to a profile, say UserObject.

Additionally I want to abstract the actual implementation of the entity by only working with interfaces so the consumer of the framework has the freedom to switch implementations, e.g. for unit testing or later in the development phase of the application.

Finally I want the consumer of the entity to be blissfully unaware of Commerce Server sitting underneath the repository; basically a full implementation of the repository pattern as outlined by Martin Fowler.

With that in mind we end up with a basic class hierarchy in place as depicted in the class diagram in the picture to the right.

Mapping Engine

ProfileMapper With the basic class hierarchy in place lets take a look at how the actual mapping of a Commerce Server profile to an entity happens.

Interestingly the Profile System operates with a type system completely separate from .NET and indeed COM making mapping interesting. The type system is pretty weak and doesn't express everything needed to perform mapping of all data types. For example there's no way of telling the difference between an association between two profiles and a string; they both turn up as a string.

To work around this limitation I went with assumptions based on the target of the mapping. So from the type of the actual target property on the entity I can deduce that we're dealing with an association because the actual type is IProfile and not string. Same thing goes for GUIDs and strings which also show up as the same thing; a string. Now I love the string type as much as the next guy but this is borderline ridiculous :)

To perform the mapping I employ a mapping engine which knows about all the mapping rules supported by the engine like rules for handling primary keys, one-to-one relationships, one-to-many relationships, value types, DateTimes, Guids, etc..

Each rule is an implementation of the specification pattern meaning that the engine will evaluate against each mapped property of the target entity and determine whether a particular rules is applicable to current property. Each rule employs reflection to determine whether that is case so the GuidMappingRule would use reflection to determine whether the type of a property on the entity is in fact a Guid.

Creating a Mapped Entity

To create a mapped entity you need to perform three simple steps: Create the interface which will expose the entity, e.g. the IUser interface. Second create the actual implementation of that interface, e.g. the UserObject class. The third and final step is to decorate the properties of the implementation with mapping information. Simple and easy. The code for IUser and UserObject might looks like this:

 

public interface IUser : IProfile

{

    string FirstName { get; set; }

    string LastName { get; set; }

    IAddress PreferredAddress { get; set; }

}

 

[Profile("UserObject")]

internal class UserObect : IUser

{

    [ProfileProperty("first_name")]

    public string FirstName

    {

        get { ... } set { ... }

    }

 

    [ProfileProperty("last_name")]

    public string LastName

    {

        get { ... } set { ... }

    }

 

    [ProfileProperty("PreferredAddress")]

    public IAddress PreferredAddress

    {

        get { ... } set { ... }

    }

}

 

Loading an Entity

With the mapping complete loading an entity is pretty straightforward: You new up the profile repository and call the generic method Get<T> with the key of the profile you want and presto you get an instance of the IUser interface returned to you complete with associated entities, the preferred address in the case. The Key class might seem superfluous but there's a point to it as it enables support for multiple key types like Guid, int, etc..

 

IProfileRepository profileRepository = new ProfileRepository();

IUser user = profileRepository.Get<IUser>(new Key("{EEDA89C9-E231-4002-AC24-7FD7FAB2F2FD}"));

 

All the Rest

Your spider sense is probably tingling by now. How's the ProfileRepository able to figure out which implementation of the IUser interface to instantiate? The answer to that is a piece that I omitted in my previous description: Sitting inside the ProfileRepository is an inversion of control container (IoC), in this case Windsor from the Castle project, which dynamically instantiates the correct type based on a configuration file.

Interestingly Windsor will be a key component in coming features in the ProfileRepository. As it stands today there are a number of improvements that can be made to it. Most prominently is implementation of lazy loading. All associations are eager loaded today which means that if you ask for a any one profile entity you'll get a complete object graph back which might not be suitable for all scenarios especially if we're dealing with many associated profiles.

With Windsor in place I intend to employ dynamic proxies to instantiate modified types with the lazy loading pattern injected into the relevant properties. Thanks goes out to Søren Skovbøll who came up with the idea for this and even provided me with POC code. His general knowledge on ORMs came in handy for a couple of things on this too :)

There are several opportunities for other performance improvements. The ProfileRepository uses reflection quite extensively to perform the automatic mapping which as you know is a costly operation. For a future release of this guy I'd like to throw in some caching for the rules which employ the reflection routines. The net result here would be that the rule is evaluated once per property and entity and from that point on reflection is only used for actually initializing the values of the properties.

Finally the ProfileRepository is load-only at this point and naturally I'd like to get create and update functionality in there as well. A customer self-service module would definitely need this feature in place to enable users to edit their user profiles, signing up for newsletters, etc..

With ProfileRepository I've tried to bring the full power of the profile system as a general purpose data access to bear in the sense that what we've got with the profile system is very cool and flexible but needs just that little bit extra to provide a nice development experience as well as something that supports the overall maintainability of the system.

posted on Thursday, 13 March 2008 21:46:16 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback
# Wednesday, 12 March 2008

Commerce-Server-2007-Logo Imagine this scenario: The year is 2003 and you're a Commerce Server developer who is setting out on the first Commerce Server 2002 and .NET project. Exited? You bet I was :) Way back we were asked to subcontract on a large ticket booking system developing the user profiling piece for the solution. With my background in OO naturally I wanted to go ahead a create business entities from the profiles in Commerce Server by inheriting them building entities specific to my needs.

Now you know what I ran into by trying to do that right? Pretty much a brick wall behind yet another brick brick wall. What I ran into was the fact that the Profile class is sealed and the brick wall behind it was the ProfileContext which is also sealed. Pretty much my idea was dead in the water at that point. So to return to the point of this post. Today several years after the fact it dawns on me that I have the perfect new tool to actually get some of what I wanted back then: Extension Methods.

As you probably know extension methods is a way of spot welding new functionality onto existing classes whether they are sealed or not. Basically a handy way of making external functionality available where you need it. Lots and lots of articles about extension methods have been written about the topic so suffice it to say that you put your extension methods in a particular namespace and to make them available on the target types you simply import them into your current context via a using or Imports statement depending on your particular language fetish :) With that out of the way lets skip right ahead to how you might use them in Commerce Server.

You can envision a scenario where you augment the profiles with specific functionality based on what you're doing. Say you're creating a product review profile in which you store the customer's opinion about a particular product. Use extension methods on that guy to include rendering a star rating, setting the customer review description, or administrative methods like approve/reject review.

For the product classes like ProductFamily, Category, etc. which are also sealed you could opt for something else entirely. From time to time we utilize the concept of search category, i.e. a category where the child categories and/or products are determined by a search criterion. Instead of putting this functionality in a helper somewhere you could go for a extension method to load the child objects of your current search category.

But why go for the individual entities themselves, why not go for the services published by Commerce Server like ProfileContext or CatalogContext to provide enhancements to the core functionality? I can certainly see some interesting scenarios enabled in the Marketing system, a subsystem which traditionally hasn't been very open to extensions.

To sum up extension methods is a brand new extension point for Commerce Server. Commerce Server has traditionally been very extendable but some areas are completely locked down. Until now that is. The scenarios I describe above is one way to do away with a lot of helpers floating around. Of course a much better way of accomplishing this is fashioning a facade layer on top of Commerce Server which will accommodate not only your custom logic but more importantly support your automated test suited (you do have one, don't you? :)). The facade layer will be the subject of a future post as I feel very strongly that architecturally this is a great thing to have in place to support you now and in the future.

Also let this post be a cry to the powers that be at Cactus to open up the APIs for inheritance. I certainly understand the need for sealing stuff especially with COM lurking under the covers but please, pretty please don't let that baggage spill over in future versions when COM is completely removed from the product. Finally sprinkle some interfaces on top and I'll promise to be a good boy from here on in :)

posted on Wednesday, 12 March 2008 16:28:20 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback
# Tuesday, 11 March 2008

Final proof that spammers are the root of all evil? Should I be worried at all that diabolical powers are taking over my inbox? Or even more worrisome that I took the time to actually make a post out of this? :)

Spam-666

posted on Tuesday, 11 March 2008 19:44:38 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback
# Monday, 10 March 2008

aspnet A quick note to let you know that this Saturday we open the doors for the first code camp in the history of Aarhus .NET user group. The fun starts at 9:00 and we're digging into ASP.NET and building a blog application, just because we can :) The goal of this code camp is to give you a sense of what's available in ASP.NET and how to use some of it.

During the day you'll be able to ask the experts for help and meet some of your fellow aspiring ASP.NET developers.

Please note that the number of attendees is capped at 12 as we can't seat any more than that.

Read more and sign up.

posted on Monday, 10 March 2008 21:35:43 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback

CarboniteLogo For a while now I've had a nice file server sitting under my desk at home for storing everything in a nice central location. One problem with the solution though is the complete lack of backup on that particular box. I really wanted to run Mozy on the box to get everything backed up off site in a simple and cost effective manner. One problem though: Mozy Personal doesn't support Windows Server which is running on my file server.

In my post Online Backup: Carbonite vs. Mozy I declare Mozy the winner due to a number factors like features, performance, and configurability. What I failed to mention though is the fact that you cannot use Mozy Personal for backing up a Windows Server box. For that you have to spring for a professional plan where you're charged by the gigabyte instead of a flat rate. For me that's not really an option as I've got a look of stuff to back up. For a couple of gigabytes it's probably fine.

Carbonite however allows you to back up a Windows Server box with the personal edition which means that it's a more cost effective solution for the home. Since I did the comparison Carbonite has added the number one feature I felt was missing from the solution: Version history. Mozy had this and Carbonite now does too. One thing hasn't changed though, Carbonite is still pretty slow to the tuned of 100k/s when you back up. Mozy will complete the initial backup approximately four times faster than Carbonite. Not a big deal once you're over the initial backup and into regular running mode with only updated files are transferred but getting over that initial hump does take a long while.

So to sum it up: With Carbonite allowing you to run the client on a server box it's a compelling offer for those of us running home servers wanting offsite backup. For everything else I'd still say that Mozy is superior. Alternatives like Amazon S3, JungleDisk (using S3), etc. are still way more expensive to use since they too charge by the gigabyte.

Mozy allows you to pay by the month allowing you to opt out immediately should you find a better solution. With Carbonite you're locking in for a minimum of a year. Where. Network performance with Mozy is a lot better than what you get with Carbonite, though that might just be me being located far away from the Mozy data center. The Mozy client still offers oodles more configuration options than what you find in the Carbonite ditto.

posted on Monday, 10 March 2008 21:06:49 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback

SharedView-Start-SessionIt's been a while since I updated my toolbox so I thought I'd do a little post about my most recent addition: Microsoft SharedView.

What is SharedView? As the name implies it's a way of sharing what you see on your computer with others remotely. I've had to muck around with LiveMeeting a lot lately and boy is that a piece of work in the sense of me not being able to get anything done within a reasonable amount of time. Setting up a shared desktop experience with that stuff is like swimming in molasses: A lot of effort and very little reward. You have to pay to use it too.

Contrast this experience with SharedView where you're up and running in a matter of a couple of minutes. Did I mention that's completely free to use? To test out SharedView I tried it out with a partner abroad. I hadn't mentioned anything about it before the meeting but we literally had the program up and running within two minutes sharing the presentation that I needed him to see. Cool stuff! The experience has that Apple-feel to it: I got the job done, nothing more, nothing less.

SharedView allows you to share a single program window or the entire desktop and you can hand over control of the window to any participant in your current session. Setting up a new session is a simple matter of you logging in with your Live ID and clicking "Start new session" which will provide you with a link you can send to the participants of the meeting. That's it.

I definitely see this little gem coming in handy with customer meetings where we need to do sprint demos but can't come on site to do so. With a new delivery going down each month having the entire dev team on site is somewhat of a drain on the customer.

Download Microsoft SharedView

posted on Monday, 10 March 2008 20:44:54 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback
# Monday, 18 February 2008

Microsoft_Team_System_Logo I'm proud to announce a very exiting meeting for Februar: The guys at Systematic are going to tell us all about their experience with Team System. Topics for the meeting include:

  • General introduction
  • Configuration management
  • Continuous integration

Following that we'll some insight into the world of software engineering at Systematic working with CMMI level 5 and agile processes like SCRUM.

The meeting will take place February 27th 18:00 at:

Systematic Software Engineering A/S
Søren Frichs Vej 39
8000 Århus C.

Signup and more information

posted on Monday, 18 February 2008 11:15:49 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback