On the forum there was a suggestion that a person should use a container control that had a few controls embedded in it at design time. And then when using that container control that they should skip providing an API that the container presented and just reach inside the container and manipulate the controls it contain directly.… Read the rest
Code for safety II
Back when I wrote Code for Safety I gave one example of something that I’m sure we’ve all done from time to time. Saving the state of some flag and then returning and having possibly multiple places to reset the flag we saved.
There’s another thats is more common with the advent of HiDPI support for Windows; drawing in a listbox event like CellBackGroundPaint Saving the graphics state, disabling antialiasing, and then needing to restore that state.… Read the rest
Why shadowing should be avoided
We’ll create a sample project to demonstrate why its a bad thing to do.
Start a new desktop project.
Add a new Class that is a subclass of ”CancelButton” by dragging a CancelButton from the library to the Navigator.
Name this new class “myPushButton”
Add a property to it – enabled as boolean
Make sure the property is public
Now on Window1 add an instance of this new button subclass.… Read the rest
Follow up on what type am I ?
Back when I was still at Xojo I wrote a blog post about what type of variable am I ?
This is a follow up on that to maybe help explain things more.
The particular difficulty is arrays. They are simple and can cause deceptive an hard to find bugs BECAUSE they are so easy to use and the Xojo language appears to do what you intend (but I don’t think it is doing the wrong thing).… Read the rest
An extensible class factory
Some times you want to make a nice generic class that a user can extend via subclassing.
However, one issue arises with this.
How can a factory method in the super class create instances of the subclasses ? This is especially troublesome if the classes you have are encrypted so you cant change the source or in a plugin.… Read the rest
Code for safety
Lots of time you see code like
static flag as boolean
if flag then return
flag = true
// rest of method
flag = false
In a simple method/event with only a handful of lines there’s probably nothing wrong with this
But what do you do when the method spans into hundreds or thousands of lines ?… Read the rest