Reply to comment

Precedent

Good point. Both Independent and Dependent derive from a common base class: Precedent. The relationship I describe above is actually between a Dependent and a Precedent. I just tried to simplify things by showing Independent directly.

So since both Independent and Dependent derive from Precedent, either one can be the source of data for a Dependent. This opens the way for indirect dependencies. To finish this story, we have to build up and tear down that relationship.

A Dependent-Dependent relationship is built in the same way as a Dependent-Independent relationship. While the target Dependent is updating, it accesses the source Dependent. This calls OnGet(), which does two things. First, if the source Dependent is OUT_OF_DATE it pushes itself onto the Current Dependent stack and updates itself. Second, it sets up the two-way connection with the target Dependent.

The tear-down is just a little different. Independent has an OnSet() method, which triggers the tear down (as described above). Dependent has no OnSet() method. Instead, it tears down relationships with it's dependents when it goes OUT_OF_DATE. This process is recursive.

The description in the article is incomplete, but indirect dependencies are still not magic. They are simply recursive.

Reply

By submitting this form, you accept the Mollom privacy policy.