With Windows Workflow Foundation (WF4) you can author activities in Code or XAML. Each has advantages and disadvantages
Advantage – XAML
You can author them in the Workflow Designer. Here is a activity I’ve been working with today. You can easily see what this activity does by looking at it in the designer.
It’s not as though code is inscrutable. You can look at it and read this but it isn’t quite as easy. Not to mention that you have to learn how to work with the Workflow object model in code.
Advantage – Code
Because there is no deserialization from XAML, there is a slight performance advantage to code based activities. The amount of difference you will see depends on how many iterations of a test you run. If I create the activities and invoke them in a loop 10 times the performance difference is about 20% faster with code.
However if I run them in a loop 10,000 times the performance difference is much less in fact it is so small as to be barely noticeable.
Of course, you must remember to cache your activities.
Which should you use?
Most people will use XAML activities because they like working with the activity designer. If you are authoring activities for others to use, it is difficult to know how much of a penalty the XAML serialization will be. In this case it probably makes sense to author your activities in code. All of the activities we ship are authored in code for this reason.
Twitter: @ronljacobs https://twitter.com/ronljacobs