C
Charles Law
As a matter of practice, where would people put the following elements of
object creation/initialisation:
Create shared member objects
Initialise shared member objects
Create non-shared member objects
Initialise non-shared member objects
Initialise peripherals
The places where these could take place would appear to be
Constructor
Initialise method (or Load method)
.... any where else?
Is there any convention for naming an initialise method?
The scenario I have in mind is where an object communicates with some
external equipment. This object needs to load its configuration from some
xml files before it can do anything sensible, but I am not sure whether the
constructor is the right place to do this. The object does not always have
to communicate with the external equipment (it might not be attached, for
example). In this case, I do not want to insist that the user connect the
equipment and power it on just so that they can use some features of this
object. It's a bit like the WebBrowser control and mshtml (loosely). The
user can load the browser and render html, or just use the mshtml bit for
parsing and stuff.
In my case, the object can be used to control the external equipment, or
used to provide general configuration information about the equipment.
Any and all thoughts welcome.
TIA
Charles
object creation/initialisation:
Create shared member objects
Initialise shared member objects
Create non-shared member objects
Initialise non-shared member objects
Initialise peripherals
The places where these could take place would appear to be
Constructor
Initialise method (or Load method)
.... any where else?
Is there any convention for naming an initialise method?
The scenario I have in mind is where an object communicates with some
external equipment. This object needs to load its configuration from some
xml files before it can do anything sensible, but I am not sure whether the
constructor is the right place to do this. The object does not always have
to communicate with the external equipment (it might not be attached, for
example). In this case, I do not want to insist that the user connect the
equipment and power it on just so that they can use some features of this
object. It's a bit like the WebBrowser control and mshtml (loosely). The
user can load the browser and render html, or just use the mshtml bit for
parsing and stuff.
In my case, the object can be used to control the external equipment, or
used to provide general configuration information about the equipment.
Any and all thoughts welcome.
TIA
Charles