Need for getChildDevice and addChildDevice

I'm working on an app that will input a sensor state and depending on the state will control a Z-Wave relay(s).

Looking at the BRavenel example he uses getChildDevice and addChildDevice at lines 45 & 46 then at line 77.
At first I thought this created an "instance" of the including app, however reading the documentation I don't see a reference to either of these.

I'm missing a concept here, can anyone suggest a reference to read or understand the function and when they are required?


I usually use this as a reference: Composite Devices (Parent-Child Devices)

addChildDevce() and getChildDevice() will return a reference to the created or specified device object (technically a DeviceWrapper/ChildDeviceWrapper). This is the same kind of reference you'd get from selecting a device with an input, for example--so you can call commands, etc. on it (actually it allows for a bit more than an input since it's parent/child and you're not limited to commands but rather any method).

I'm not sure where an instance of an app fits into this question or the use of these methods in the code. If this or the above doesn't help, maybe explain a bit more about what you're thinking, and someone can provide a better explanation.

Thank you ......... digesting.