What is a dependency property?

Explanation without code

Think of it like this:

Everyone is more or less the same

Human beings have a lot of information associated with them. Countless hundreds and thousands of data is associated with you – how many fingers you have, how many toes, how many BRCA2 genes you have etc etc.

Now here’s the problem: Somebody might ask you these questions at any one time, and you should be able to give them a straight answer.

So the question is: how can you remember all of that? Well, originally people started writing all this stuff down, but soon they realised they would need to carry around the entire library of Alexandria in their back pocket to be able to answer all those questions: that’s waaaay too much stuff to lug around.

Store common information in one place

So someone had a bright idea. They noticed that most of the time, the information is the same. Most people have the same data, and very rarely does it change. Most people have:

  • one heart
  • one face etc.
  • three BRCA2 genes

There’s no need for every single person to carry around that information. You can store all of that information in one place, in one a central library. But there are always exceptions………if you have any exceptions, then you’d simply carry those exceptions around with you in your back pocket. For the most part, people are very much the same. If you don’t have an exception written down, then you can simply refer the interviewer to the data stored in the common repository.

Example: Reporter interviews President Donald Trump**

Let’s try this with an example.

We have an instance of Person: Donald Trump. A news reporter is asking our esteemed President some questions:

“Mr President Trump, how many HIF1A genes do you have?”

Donald checks his back pocket. There’s nothing listed there about how many genes he has. So he simply tells the reporter that he has the default number that everyone else has. So the reporter simply goes to the library to find out about that particular detail.

“Mr President Trump, how many faces do you have?

“Excuse me!” says Donald Trump, without a sharp jab of the finger, “Fake news!” he sneers. He then reaches in his back pocket to check whether anything is written there. There is: he’s got 2 faces. There’s an exception here. So he can’t ask the reporter to refer to the library, because this is an exception. Trump should promptly returned with the answer: 2, but in reality we all know that he would instead throw a PuerileTantrumExcpetion().

Value resolution up a tree

To simplify it, things are resolved first with the person, and then upwards, to the library, and if the information isn’t contained there, then the question goes to a higher authority: either God or the Spaghetti monster as the case may be. In the end, all answers get resolved.

Summary

That’s the concept in a nutshell. It’s a property that gets resolved, first by the person, and if not there, then upwards till an answer is obtained. I hope that makes sense.

Written on June 20, 2017