I recently discovered Pex and Moles. A bit late for sure, but better late than ever I suppose.

While Pex is cool in the way that it creates automated unit tests which are somewhat tiresome to do (test all exception cases etc) so you as a developer can focus on creating unit tests that are really worth something (to be honest I haven’t tried it out that much), Moles is really the cool bit.

TDD is something every development team should do, or are doing. But let’s face it, you have to do a lot of workarounds to your code to be able to stub or use a mocking framework. There are good patterns for it but it is still time consuming to always make sure your code is testable. And unfortunately not everyone likes testing :(

With Moles however, you can design your code the way you like, and then overriding whatever you like in your tests using delegates. Even things buried deep in the framework itself. It is simply but, the best thing since sliced bread.

So, for the client I am currently at I’ve had a few EF4 projects, mostly focused on creating applications which are easily maintained, if new developers arrive or the code is not looked upon for a long period of time. I’ve really enjoyed EF4 in that aspect, it is simple to use, easy to read, extensible, and I especially like the way I can create n-tier applications using self-tracking-entities for those situations I need a secure application and serializing entities over WCF where I own both client and server.

But, there have been a couple of projects where performance has come into play as well, and although I always make sure the linq queries I or anyone else create, are closely inspected either by casting to ObjectQuery or using the excellent tool “LinQPad“, the SQL queries generated are really really ugly sometimes. Especially if there is a situation where you need to use eager loading. For EF v4 this excellent blog shows how to create your own T-SQL queries (ExecuteStoreQuery<T>) and map them to your entities, and also how to use Translate<T> to map multiple result sets to entities.

For EF v1 you need to download EF extensions, which I haven’t used unfortunately, but I expect the code to be a bit different from how you use EF4, so take the time to upgrade to VS2010 and .Net Fwk 4 instead.

Some of you have e-mailed me regarding Daily Comics. The server is currently down and will be moved to another location this coming weekend. So have patience, it will be back up again soon!

Good news everyone!

Entity Framework v4 (wasn’t it v2??) beta has been shipped with the beta 1 of .Net 4.0 according to this InfoQ article: click here

Apparantly it is available for download if you are an MSDN subscriber, so I will try it this weekend.

Entity Framework version 1 which arrived in .NET 3.5 SP1 is an incomplete framework. I would probably classify it as an early alpha version. Version 2 promises much more, but it is still unclear what will be included in the new version, or when it will ship.

The Entity Framework team maintains a blog on http://blogs.msdn.com/efdesign/ which I’ve linked to in earlier posts. One of the new things in v2 is something called Self-Tracking Entities. In previous posts they wrote about creating an architecture that facilitated this, but said it was left to the developer to create the implementation. Many, myself included, complained about this on the efdesign blog saying that the Entity Framework team needed to create a reference implementation. So it’s nice to see that they are listening to the users. I encourage everyone to read their blog and keep commenting what they do, they seem to listen =)

It is still unclear how this will end up since no details are given, still it seems promising for those who create N-tier solutions across technologies such as WCF for example.

Well this came as a surprise to me. Apparantly Microsoft is not following its own coding guidelines for implementing the IDisposable interface for ICommunicationObject (implemented by, for example, ServiceHost, ClientBase, IChannel etc). This means that when calling Dispose() an exception can occur and the connection may still be open.

You can read all about it here:

http://www.infoq.com/news/2009/03/WCF-Dispose

Microsoft has guidelines here on how to try/catch instead of using Dispose():

http://msdn.microsoft.com/en-us/library/ms733912.asp

3rd Mar, 2009

Agile Anti Patterns

Succeeding with Agile methods such as Scrum is not as easy as it seems like at first glance. Many projects use only bits and pieces that they need and do not consider the whole process.

For instance, using Scrum in a programming project requires that the team adopts concepts such as XP (continuous integration, TDD etc). If it doesn’t the technical debt introduced into the project will increase faster than you would like to know.

Over at InfoQ there is an article about antipatterns concerning scrum, this one focuses on distributed teams but it is still an interesting read.

http://www.infoq.com/news/2009/02/distributed-agile-antipatterns

It also contains the following link to an article written by Clinton Keith and Mike Cohn. Its topic is “20 tips to avoid success in an Agile project”.

http://www.berteigconsulting.com/sites/default/files/HowToFailWithAgile.pdf

Happy reading!

Earlier I wrote about POCO in EF and how I wondered how the POCO model would be implemented.

Shortly thereafter that I found this: EF POCO Adapter

EF POCO Adapter enables Plain Old CLR Objects (POCOs) to be tracked using released version of Entity Framework V1. It consist of a code generator, supporting library and a test suite and examples.

Code generator writes an adapter layer that will translate between POCO objects and Entity Framework-aware objects and provide services on top of POCO objects, such as:

Change tracking (snapshot-based and proxy-based when possible)
Transparent lazy loading
Immutable Value Objects
Queries (LINQ and Entity SQL)
Shadow state (maintaining certain persistence-related fields outside of entity class)

Entity Framework V1 programming interfaces are wrapped with corresponding APIs that work with POCO objects and do necessary translation between POCO and Persistence-Aware objects.

It’s basically a technological demo of a code generator that generates POCO objects from your *.edmx file. I encourage everyone who has an interest in EF’s future to download and try the code.

30th Oct, 2008

C# 4.0

You can now download information and examples on the new version of C#, 4.0, on http://code.msdn.microsoft.com/csharpfuture/. This document summarizes the new features: New Features in C# 4.0.

The most major update is the interaction with Dynamic Languages such as Python, Ruby etc, with a side effect of improving COM-interaction as well. This is done through a new type called dynamic.

It will also be possible to set default properties in methods, like this:

public void Foo(int i, string bar = "hello")

This method can then be called like this:

Foo(35); // omit the default property
Foo(bar: "goodbye", i: 35); // reverse the order of the properties

This opens up a new world of possibilities (and when I say possibilities I don’t necessarily mean that in a good way).

27th Oct, 2008

Certified Scrum Master

Last week I attended the Certified Scrum Master course , arranged by Crisp. I can highly recommend the course, mainly because of Jeff Sutherland, whose anecdotes and case-studies were truly eye-openers.

I’ve been using Crisp’s, or I should say Henrik Kniberg’s, scrum method since December last year when Crisp implemented it at my previous client, but still found the course highly educating because of this.

Categories