Why we replaced dependancy property-binding cocepts of 3.5 with new concepts of Arguments & Variables?
-
Friday, June 26, 2009 5:51 AMThough it may sounds like a silly question, i would like to know the conceptual defination of arguments & variables. I would like to know what benifit we achieved by this over 3.5 in WF 4.0. It would be great if we have some technical document explaning about Arguments and variables.
All Replies
-
Friday, June 26, 2009 6:30 PMModerator
There will be a deeper description of the data model coming with later MSDN documentation releases. I do not know the specifics of that timeline.
As for the short version:
An argument defines an input to or an output from an activity. You can think of this as its public contract much like the parameters for a method. A user of an activity is expected to bind values to the input arguments and "locations" to the output arguments. A location is simply a place that data can be stored in the workflow data model.
A variable defines a storage location. There really isn't that much more to say about that.
As an example:Variable<string> toWrite = new Variable<string>(); Sequence sequence = new Sequence { Variables = { toWrite }, Activities = new WriteLine { Text = toWrite } };Here we are declaring a single storage location at the scope of our Sequence. That means the variable is visible to everything in the Sequence's subtree.
On the WriteLine activity we have a single InArgument<string> named Text. We are specifying that the value of Text should be taken from our "toWrite" storage location. In WriteLine's implementation it uses the Text argument to access the value. WriteLine itself never knows about the storage location that the value came from ... it just knows about its argument.
So, what are the benefits of changing from the dependency property model:
* Performance. Since the storage location toWrite is declared at the scope of the sequence that means that (1) we don't have to actually allocate a storage location until the sequence starts executing and (2) we can dispose of the location once the sequence completes. Contrast this with dependency properties which allow arbitrary binding without any scoping. In that world we have to keep all state around at all times because it could be accessed before, during, or after the lifetime of the activity owning the property. In the end this allows us to reduce the amount of the workflow tree that we need to persist. We only have to persist the currently executing activities. In 3.0 if you had a sequence with 1000 children we'd have to persist 1001 activities at each persistence point. In 4.0 we only need to persist 2 activities: the executing sequence and the currently executing child.
* Data flow analysis. We currently don't have any data flow analysis features built on top of the stronger data model, but the new model provides for the ability to do data flow analysis. This includes things like the ability to detect using unset variables or using the same storage location in parallel branches.
* Dynamic update. In 3.0 it was not possible to dynamically add a new storage location. Since storage is now modeled as a variable (as opposed to just a CLR property), new storage locations can be dynamically added or old storage locations can be dynamically removed. The stronger data model allows us to detect if an activity references a storage location that doesn't exist in the tree.
- Marked As Answer by Darshak Vaishnav at Eclipsys India Saturday, June 27, 2009 10:38 AM
-
Saturday, June 27, 2009 10:16 AM
Hay,
Thanks a lot for throwing such a nice,descriptive light on the same..got the higher level idea from it, eagerlly waiting for MSDN documentation for further in & outs about the same.- Marked As Answer by Darshak Vaishnav at Eclipsys India Saturday, June 27, 2009 10:36 AM

