views:

159

answers:

1

I just started working with WF and what I find really annoying is that you have to name so many things. IMO, one of the most difficult things that a programmer deals with every day is constructing good names for things, and WF seems to take this to the extreme.

Take the WF IfElse Activity for example. If I were coding this in raw C# (not using WF), it would look something like this:

if( x == 0 )
{
    // ...
}
else if( x < 10 )
{
    // ...
}
else if( x < 100 )
{
    // ...
}
else
{
    // ...
}

Now the above C# code is simple and concise. In contrast, if I were to define a Windows Workflow which does the same thing using the IfElse activity, first off I would have to name every if block: e.g.

  • ifXEquals0
  • ifXLessThan10
  • ifXLessThan100

On top of that, I would have to name each condition in every if statement: e.g.

  • xEquals0
  • xLessThan10
  • xLessThan100

Not only is this tedious, but hard to maintain (e.g. if conditions change) and error prone (you forget to change name when condition changes).

The problem (from what I can tell) is that WF breaks down every programming construct into properties of the workflow, which needs a name.

Now since I'm still learning WF, and I don't want to sound like a know it all... I want to ask you folks. Am I doing something wrong? Is there a way to avoid this name-itis when creating WF workflows? Is this something specific to Windows WF, or do other workflow engines suffer the same thing?

+1  A: 

The problem (from what I can tell) is that WF breaks down every programming construct into properties of the workflow, which needs a name.

Actually, the reason you need to have different names is because each part of that if-else statement that is represented in your workflow is actually an individual IfElseBranchActivity, not just a property of the workflow and therefore must be uniquely named.

As far as maintenance is concerned, take a look at using a ruleset to help out with the actual boolean tests themselves. That might make it easier to modify at a later point in time.

MattK