# Tuesday, 13 May 2008

aspnet During my ANUG talk about the ASP.NET MVC Framework a question came up regarding what the landscape of ASP.NET land would look like with ASP.NET MVC being open source. Would we start to see lots of different branches floating around out there?

The answer to this is a resounding no as the license model of ASP.NET MVC only allows for you to download the code off of CodePlex, make changes, but not redistribute those changes.

What this means that you'll be able to take the code make tweaks here and there if you're not satisfied with how a particular aspect of ASP.NET MVC works.

The Gu has the word.

posted on Tuesday, 13 May 2008 09:23:26 (Romance Daylight Time, UTC+02:00)  #    Comments [4] Trackback
# Sunday, 04 May 2008

anug_logo_200x85 Our eleventh meeting is over with and I'm particularly relieved as I was doing the talking the entire evening this time around. Before I tell you more about it first let me take you through the user group news.

2008 Booked

I'm happy to announce that we've booked speakers for the rest of 2008 which means that we'll be able to take a breather until 2009 :) Getting people to present is just half the battle; we need a place to hold the meetings as well and we're not completely set on that front.

So which topics are we going to cover in the meetings to come? By popular request here's the complete list:

  • May, Windows Communication Foundation, Klaus Hebsgaard
  • June 20th, Geek Dinner
  • June, Test Driven Development, Mark Seemann
  • July, Open Space: Pro Tools
  • August, Subsonic, Lasse Eskildsen
  • September, F#, Christian Holm Nielsen
  • October, Usability, Søren Skovsbøll
  • November, BlogEngine.NET, Mads Kristensen
  • December 12th, Geek Christmas Dinner, *.*

I'm very happy about this list I'll tell you that :)

New Web Site

We talked about this forever and now, thanks to Peter, our new web site is a reality. Peter did a bang up job with the new web site and I sincerely hope that it becomes the hub of information on ANUG in the future instead. LinkedIn will still be the way to gain membership and Facebook will still drive sign ups for the meetings but anug.dk will bind the information together for us.

To keep non-Facebook users up to date with new meetings we hope to integrate the new web site with the ANUG backend system: Google Docs :) We keep information about upcoming events and ideas in a Google Docs spreadsheet which I created some code to access via the Google API. Peter is integrating my code into the web site as I type this :)

In a related note anug.dk was hacked due to a security issue in BlogEngine.NET. Kudos to Peter for updating with the security patch literally within minutes of learning of the hack. Everything is back in full operation as of writing this. If you're running a BlogEngine.NET site be sure to check out official response to the security issue.

Mile Stone Reached

ANUG reached a significant milestone during April: Our 100th member. Actually we're up to 107 members right now a number I'm very pleased with. What does this mean for ANUG?

It means two things: First we're doing something right here which is nice to know :) and second we're suffering from our own success as finding place to hold our meetings is becoming increasingly difficult with more and more people attending our meetings.

A positive problem to be sure but something we have to deal with nonetheless so I'd like to take this opportunity to call for help from companies with ample space to house 30 - 40 .NET devs talking tech. Please e-mail me if you're able to house us for a meeting or two.

Vertica, Kristelig fagbevægelse, Ditmer, Scanvaegt, Systematic, Up-Site are all examples of companies which are supporting Aarhus .NET User Group and by extension the .NET community. A few new companies are lined up to help in the future including iPaper, Suzlon, and Vesta.

ASP.NET MVC Framework Presentation

aspnet It was with some trepidation that I looked at the number of people signed up for the ASP.NET MVC Framework presentation. For one thing I wasn't sure that we'd be able to fit everybody in the Up-Site offices and secondly I was giving the presentation :)

As it turned out we were able to fit everybody; barely. We had to highest turnout ever with approximately 35 people in attendance. I was particularly please with the fact that a number of new companies were represented at the meeting including Mjolner Informatics and Vola. The Nordic Company-guys even made the trip all the way from Copenhagen to Aarhus to attend for the second time.

I'm very pleased with the way my presentation went. From the very start we had good interaction with lots of questions and remarks about the new web framework from Microsoft. Even my demos went off without a hitch, incredible! :) My Poor-Mans-Update-Panel seemed to come across particularly well.

Thanks to everybody there I had a good time presenting this stuff. Oh yeah I thought I'd better link to the most popular slide of the evening (You probably had to be there to get it though) :)

Tour de Up-Site

Up-Site-logo Up-Site is an interesting company I'd never heard of before we started ANUG. Actually Morten Bock, a developer with Up-Site, was one of the very first people I shook hands with at the very first user group meeting. Morten was kind enough to facilitate some nice surroundings for our April meeting.

Now what is that makes Up-Site so interesting? For starters they have a very clear idea of their business model and it seems that that was the case from the very beginning. As the CEO Lars Henrik Larsen told us Up-Site specializes in helping  companies select the right content management system; very competently I might add. Up-Site specializes in no less that five different CMS'es ranging from the high-end right down to the free and open source.

Their offices are among the nicest I've visited yet. I could really tell that the guys at Up-Site have attention for detail with nothing being left to chances decor-wise. Very nice and definitely not something you see everyday as developers tend towards the functional and not much else :)

A nice touch is their wall of fame which holds a little plaque for each of their delivered solutions. A pretty comprehensive wall of fame too.

posted on Sunday, 04 May 2008 22:50:29 (Romance Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Friday, 25 April 2008

Vertica_Logo My good colleague Daniel has joined the blogging fray. He's been at it for a while too before telling anyone about it so he's got a nice bunch of posts up already and keeping up the pace. He's been working on a Commerce Server/SharePoint project for the past couple of months and of course the regular C# stuff so expect to see more posts about those subjects.

Subscribed!

posted on Friday, 25 April 2008 15:30:57 (Romance Daylight Time, UTC+02:00)  #    Comments [0] Trackback

img_ecommerce With an e-commerce solution online payment naturally follows. Recently I've been involved in a couple of e-comm projects which needed integration with a payment provider.

In the good old days integration was a no-brainer you'd simply go with the API, HTTP-RPC or web services, for the nicest solution design-wise and development-wise as well.

Last year though VISA/MasterCard introduced the PCI compliance requirement for businesses handled credit card information. A move which in theory was good in that it limits the number of businesses which handle the information and by extension limits the chance for leaked information via security breach.

Now I write in theory because what happened is the VISA/MasterCard went a bit too far in their requirements. Basically if a credit card number is ever entered on your server you need to be PCI compliant; while this make sense for a payment provider for a store it means that you can't use the APIs as you'd normally would instead you have to use a payment window provided by the service provider.

If you want to handle credit card information at all you have to submit your system for quarterly reviews by external security consultants and your system will have to comply to the same standards as the payment providers themselves adding a yearly running cost of $5,000 - $30,000. Did I mention that VISA/MasterCard is bumping up the requirements on a quarterly basis? All in all this adds up to the conclusion that not handling credit card information on your servers at all is becoming the default choice and by extension the payment window becomes the default choice.

The payment window adds another layer of complexity to your solution in that you have to redirect your customer completely over to the payment provider site to process the credit card after which point the customer returns to your site to view a confirmation if everything went well. My main complaint about the payment window is the lack of contiguity for the customer. A great many sites here in Denmark use the payment windows with more or less success in that department.

Payment-Windows-Redirection-Flow

With the payment window being the default choice for now it's important that Danish online e-tailers figure out how to integrate the window in the most user friendly manner. Not doing so signals lack of professionalism in the best case and in the worst case they could loose customers because they are confused by a completely different look and feel in the most critical part of the checkout flow: Payment.

A company which does this extremely well is Trollbeads.com. Their integration with the payment window is seamless, in fact when I shopped there a couple of weeks ago I didn't even notice that I was redirected to their payment provider for processing my payment information. I should notice I do this for living :)

Take a look at the following screenshots to see what I mean:

Trollbeads-basket

(Basket)

Trollbeads-checkout-DIBS

(Checkout)

That's how it should be done and I didn't even do it myself :)

posted on Friday, 25 April 2008 15:14:53 (Romance Daylight Time, UTC+02:00)  #    Comments [1] Trackback
# Monday, 14 April 2008

Back in 2005 I wrote about the "magic" third connection available with Terminal Services with the -console switch and I've happily used it ever since. Everything was dandy until recently when suddenly it stopped working for me.

It turns out that with Windows Vista Service Pack 1 Microsoft deemed it necessary to rename the switch to -admin. Only for Windows Vista mind you and only for Service Pack 1.

So the command for getting at the console of a Terminal Services enabled machine is now

mstsc.exe -admin

Thanks Microsoft!

posted on Monday, 14 April 2008 10:36:45 (Romance Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# 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