
Vincenzo Ciancia wrote:
I wonder if a good automatic naming is possible. Maybe Glynn Clements knows by experience that it's not a good idea.
It isn't. wxMotif just names each widget after its type (e.g. all push buttons are called "button"), which makes it impossible to refer to individual widgets (Xt doesn't force siblings to have distinct names). This is the kind of thing that happens if you design a generic API without considering the specifics of individual toolkits first, and is the kind of thing that I'd like to help prevent. Also, auto-generated names wouldn't be much use for parts of the UI which have dynamic aspects (e.g. if a dialog sometimes has a "help" button and sometimes doesn't, any subsequent buttons would have varying names). And even if the UI is static, "button3" has far less mnemonic value than "apply".
People targeting other platforms first wouldn't know what to use the name for, and why it's a good idea to specify a proper name.
This is a very good argument in favour of automatic naming. Naming given by an user wich is not aware of their use would be worse than an automatic one. Or at least automatic naming should be an option for the user.
It's an argument in favour of documenting *why* widgets have names.
Also, if any examples are provided, it should be immediately apparent.
In any case, the programmer will often have to think up a name for the
variable which holds the widget's handle. The variable name is likely
to be suitable as the widget name. Ultimately, both serve the same
purpose: a means to refer to the widget.
--
Glynn Clements