« MBS Xojo / Real Studi… | Home | ChartDirector 6.0 Rel… »

Exceptions and Private Constructors

Today I added 20 new private constructors to the ChartDirector plugins. Why?

Well, we do have classes which can't really be used alone. If you create an CDAxisMBS with new command in Xojo, you only have an empty object. No internal object reference, so it's just an empty shell. To get such an object, you invoke a plugin function on another class, e.g. a chart. Like this example:

// bad old code, now impossible
dim axis as new CDAxisMBS
axis = chart.yAxis

// better code
dim axis as CDAxisMBS = chart.yAxis

Call new on a class where it's not intended causes trouble. First you have objects were any call to a method or property can cause an exception or a crash. To avoid it, I add private constructors to the classes to mark them being abstract. This effectively disallows you to subclass or instantiate them.

The documentation utility got a few fixes today. First I found over 100 items where text encoding got mixed up so you had strange characters in example code which caused confusion. Should all now be cleaned up. And those abstract classes are now also marked explicit as being abstract.

To make ChartDirector Plugin more safe in low memory situation, the next prerelease will have improvements in exception handling. Functions allocating memory should now raise OutOfMemoryException if they can't allocate memory for the work they do instead of crashing.
14 06 15 - 22:53