PDFX: First Thoughts

Quick poll: raise your hand if you

A) are a developer, and

B) have ever had to write an application with a complex graph of property dependencies.

Keep your hand up if your solution to that complex graph involved some combination of complicated property update methods, a fragile web of events and handlers wired up between properties, wailing and gnashing of teeth, or all of the above.

Brothers and sisters, put down your hands and download your deliverance: fellow InterKnowlogist Kevin Stumpf recently posted a blog series on his new Property Dependency Framework for .NET applications, PDFx. I’ve spent the last week or so implementing it for (my) first time on a project here at InterKnowlogy, and wanted to whip up a quick post on my first impressions. Since a code snippet is worth a thousand words, let’s lead with a quick example:

//Depends on value of Properties B1 and B2, and returns their summation.
public int A1
{
     get
     {
          Property(() => A1)
                  .Depends(p => p.On(() => B1)
                  .AndOn(() => B2));
          //"Property A1 depends on B1 and on B2". How cool is that?
		
          return B1 + B2;
     }
}

Yep, it’s really that simple. Fluent interface, stupid-simple declaration, and all that’s required is to inherit your model objects from a Bindable base class provided by the framework. And the best part? It all just… works, like magic. In our example above, any time B1 or B2 change, A1 is automatically reevaluated, as are any other properties dependent upon its value. There’s all sorts of great documentation on Kevin’s blog, including great info on advanced features like external property dependencies, collection dependencies (very nifty), and caching. Bottom line: if you develop .NET applications in any capacity of even moderate complexity, take five minutes to grab the code from CodePlex and check out the documentation, and if you’re not completely satisfied, I’ll send you a case of K├Âlsch as a way of saying entschuldigung.*

*German for “sorry”, in honor of Herr Stumpf’s forefathers.
*Not an actual offer.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>