Thursday, 1 May 2008

How is Windows Communication Foundation (WCF) like wargaming?

Firstly, I think it is important to clarify what I actually mean by wargaming so as to clear up any misconceptions and establish some context.

Wargaming is not running around a wood or warehouse with a paintball gun. That is called Paintballing.

Wargaming is not trudging around a field dressed as knight (or camp follower) re-enacting the Battle of Bosworth Field. That is called Re-enactment.

Both of those involve dressing up in public which I haven't done since I was a New Romantic. Crikey, this is better than therapy!

No, wargaming is grown men or women (but usually men) playing toy soldiers with, well, toy soldiers. We paint our soldiers and group them into armies and then play out a game following a set of rules (dice and tape measure required). I could go on but then we would both feel uncomfortable.

So, how is WCF like wargaming?
Imagine that you have discovered an interest in wargaming. You have seen people playing them and want to give it a try. There are so many sets of rules to choose from; WAB (Warhammer Ancient Battles), Tactica or how about WRG (Wargames Research Group) 6th or 7th Edition. Let's say that you opt for WRG 6th because some guys you know use them. The no brainer is your first army. It just had to be Romans, Early Imperial Romans (yes there is more than one kind of Roman).

You do your research and know exactly what figures are needed to create the 'killer' EIR (Early Imperial Roman) army. You purchase and paint your figures and then comes the crucial bit. The rules tell you exactly how to base your figures. i.e. what width and depth the bases need to be. The size of base is crucial to rules as they impact on the way a game is played. In the case of WRG the bases are quite narrow, 15mm per figure.

Now let's consider software. You write software. You are a 'Services Guy'. You have the four tenets of SOA (Service Oriented Architecture) on a wall poster in your office. You write connected applications.
You could have chosen to write your service as Web Services for the greater reach that HTTP allows. You could have made use of Message Queuing to exploit the latency that this model offers. You could have picked COM+, Enterprise Services to take advantage of its management of transactions or perhaps Application Pooling. Hey, you might even have opted for Remoting because 'there just can't be enough stress in a person's life!'

Regardless of this, the one thing you knew for sure is the service that you wanted to write. You knew the classes and their methods.

So we have made a start. You knew the service (army) that you wanted to write (play with). You settled on a technology (rules) that seemed to do what you wanted it to do.

Great. You have a working application.

You have been wargaming with your EIR army now for quite a while. You love your army. It looks good. Its won a few games. Its Roman! The only problem is the rules. Another set is growing in popularity, WAB (Warhammer Ancient Battles). There are a number of WAB tournaments coming up that you would love to take part in, however that set of rules uses a different size of base.

Now there is no way you are going to paint another army exactly the same as the last one simply to glue it to bigger bases.

You browse the wargaming forums and hit upon a great idea. Movement Trays ! All figures are grouped into units. For example four ranks of six figures for a unit of twenty four 'men'. As long as the overall size of the unit is correct, the rules system works. Regardless of individual base size. Brilliant! So now you make movement trays out of card, balsa wood, Plasticard, whatever, in a number of sizes. In fact, one tray per unit per rule system. So now, assuming that you read the other rule book, you can simply take your existing figures and place them into the appropriate movement tray for the rule system being used for this game.

Some trays will have a bit of space(border) around the edges , others will not.

Now if my friend would like to borrow my army for a tournament that he's going to, and he is using a different rule set. No problem! All he needs are some new movement trays.

You are now officially reusing your army!

Yes but, what about WCF?
WCF is the movement tray of connected applications. I will no doubt come up with a better analogy in time. It is a series of libraries and services that are built into the .NET Framework. Its job is to unify the existing technologies such as Web Services, Message Queuing, Remoting, COM+ etc.

You write your service in much the same way as you might write a web service. You write your client in pretty much the same way. i.e. you add a reference to your service to create a proxy that your client application can use.

The clever bit is the config file. Actually there are two. Once for the service, the other for the client application. This is where you specify the ABCs of your service.

{A} is the address of the service. What is it's endpoint? What url will the client application need to use to locate the service.
{B} is the bindings to use. What protocol to use? Should we use BasicHTTP, wsHTTP or perhaps TCP.
{C} is the contract. What interface should we use?

As you can imagine the contract (interface) is unlikely to change on a regular basis but the bindings can change as often as you like.

In fact, this might have very little to do with you at all. You wrote the service and client, deployed it and then went snowboarding (or in my case, wargaming). Yes I know I left out testing! Should we need to alter the bindings to make use of TCP for speed over the intranet or possibly wsHTTPBinding for secure access over the internet, then simply have the administrator alter the config files. There is no need to rewrite the code. After all, you need to move onto the next project.

So in fact, the config files in WCF are the movement trays of connected applications. Once I have painted the Romans, I don't want to have to paint another Roman army simply because I have chosen to use another rule set. Hell no ! I've seen '300' and am keen to paint up some Spartans !

Anything else?
Yes of course there is. However, I think I have covered the fundamentals pretty welll.

Training ?
Should you require training in WCF we currently offer the following course: 

Building Effective Windows Communication Foundation applications using Visual Studio 2010


See you soon

Phil Stirpé
"I don't do average!"

1 comment:

  1. Khoảng cách giữa Diệp Âm Trúc và Cốt Long gần nhất chỉ có hơn 10 thước . Lúc này mấy đầu Cốt Long thật lớn đã hướng về phía hắn đứng . Ngọn lửa u ám trong mắt đã sáng lên đôi chút . Hiển nhiên đã phát giác ra sự tồn tại của Diệp Âm Trúc .

    Hai tay đặt trên dây đàn của Phi Bộc Liên Châu Cầm . Đấu khí cùng tinh thần lực tăng lên đến trạng thái đỉnh phong . Diệp Âm Trúc vẫn chưa vọng động , mặc dù hắn biết nếu lũ Cốt Long này phát động công kích nhắm vào mình , tuyệt đối không có khả năng tránh thoát , nhưng hắn cũng không thúc thủ chịu đòn suông.

    Chính đang lúc này , một thanh âm già nua hùng hậu từ bốn phương tám hướng vang lên :đồng tâm
    game mu
    cho thuê nhà trọ
    cho thuê phòng trọ
    nhac san cuc manh
    số điện thoại tư vấn pháp luật miễn phí
    văn phòng luật
    tổng đài tư vấn pháp luật
    dịch vụ thành lập công ty
    chém gió
    trung tâm tiếng anh
    -Kẻ nào dám xông vào Long tộc thánh địa , quấy rối các linh hồn đang ngủ say ?

    Vừa nghe thấy thanh âm này cất lên , toàn thể Cốt Long quay đầu hướng về mặt trăng màu tím , cũng không phát động công kích về phía Diệp Âm Trúc nữa .

    Ôm Phi Bộc Liên Châu Cầm sát ngực rồi đứng hẳn lên . Diệp Âm Trúc từ không gian giới chỉ lấy ra khối long phiến mà Ngân long vương Hoắc Hoa Đức đưa cho hắn , cao giọng nói :
    -Xin lỗi , ta tuyệt không dám quấy rầy các linh hồn yên nghỉ của Long tộc , nhưng Ngân long vương