The purpose of this page is to give a quick overview of how to compose component hierarchies using the PEAK framework, using working code. I have inlined comments in the code example, so hopefully, it will be self explanatory.
Here's the code example that I came up with while working out how to compose hierarchies, and "aquire" objects from parent components in PEAK. It requires the current CVS version of PEAK (0.5a3).
Running this example should produce output similar to below:
--Joel Boehland
So, it seems to me:
This means: "When you make a ?SimpleCmp, it has within it a variable __eggs. __eggs is an Eggs. When someone asks for the ?SimpleCmp's IEggs interface, patch it through to my internal __eggs. And when they ask for the ?SimpleCmp's EGGS_PROPERTY, also patch them through to my internal __eggs."
It also seems that: If a component has another component within it, that if the child component requests an interface, it firsts check locally for it, and if it's not found locally, it checks it's parent for it. And if not there, still higher up the chain (grandparent.)
Am I understanding right?
Next, I naturally wonder: "What for? What kinds of things do you get from this?" I'm not saying there isn't, I'm just not used to thinking this way. I'd like to get excited about it, by understanding what it can do for me.
-- ?LionKimbro 2005-04-17 14:58:41
I think it is done to have a flexible InversionOfControl mechanism. That is the wiring between elements is made "magicaly". It's very flexible since you can change a piece with another without worrying to change the code of objects using it or an object doesn't have to know which object uses it.