[Gambas-user] Strange ERROR if "Utility" in Name Menu

Tobias Boege taboege at ...626...
Wed Oct 1 23:08:32 CEST 2014


On Wed, 01 Oct 2014, Ru Vuott wrote:
> Hello,
> 
> our friend of italian Gambas forum posted an his project, where a strange error is raised if the "Name" of Menu is "Utility"... 
> 
> Your opinion ?
> 
> His project here attached  (look at the "Name" of "Menu5" inside !)
> 

This is because the menu name is "Utility" and the project options say that
"form controls are public".

So what happens is: the compiler creates public variables in the form which
have the name of the controls in the form (I guess), so that the programmer
can write FMain.myMenu to access their menu control. But Utility is actually
a boolean property of the Form class already from which FMain inherits, so
the not-so-strange "incorrectly overridden" error is raised.

Our friend did two things wrong here: normally, you shouldn't tick the "form
controls are public" checkbox. Indeed the program seems to not need it at
all. It's the same as having everything be a global variable -- it nullifies
the principle of encapsulation.

The second thing is to violate the Gambas naming conventions :-) Calling a
thing "Utility" asks for trouble, "mnuUtility" would be fine.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list