Final(ly)

Some languages have to notion of FINAL for methods, events, properties and many other aspects of the language.

But what exactly does FINAL do or mean ?

In other languages, like Java, FINAL has other uses like creating “constants” which there is no need for in Xojo. In those languages a FINAL property is a constant.

In some cases though you might create a class and implement a method that you do NOT want subclasses to override. This could be needed for some algorithm where a subclass overriding the method could negatively affect the operation of the algorithm.

A good example might be something like a StringBuilder class that has an internal buffer that it uses to create a fast string building mechanism. The method that manipulates this internal buffer should be an implementation detail that subclasses should probably not be able to override.

Currently in Xojo the only way to make a method NOT overridable is to make it private. But as soon as you do that subclasses cannot call it.

In Xojo if you want this class to be subclassable you have to make its methods either public or protected. And as soon as you do that a subclass CAN override those methods.

Being able to mark a method as FINAL would prevent the ability of a subclass to subvert and take over certain critical function and still make the method usable by the subclass.