doc: addon: fix object instantiation examples

* Extend examples to show how to handle non-constructor invocation in
  constructor callback functions.

* Fix up examples to initialize member variables at object construction.

* Fix up a few naming inconsistencies.

Fixes #5701.