Jannyboy11 / ScalaPluginLoader

PluginLoader for Bukkit that provides Scala runtime classes and enhanced APIs.
https://www.spigotmc.org/resources/scalaloader.59568/
GNU Lesser General Public License v3.0
26 stars 10 forks source link

Suggestion - Facade methods #5

Open Jannyboy11 opened 3 years ago

Jannyboy11 commented 3 years ago

Since we are doing bytecode transformations already anyway, we might as well take advantage of them to implement 'Facade methods'. A 'Facade method' is a method that does nothing by itself. A bytecode transformer may take advantage of these methods and redirect calls to methods with a concrete implementation. These implementation methods may optimized for a certain version of minecraft, or specialized for certain server software. It would be an error at class-load time if an appropriate implementation method could not be found.

The advantage of this system is that it saves the programmer from implementing glue code boilerplate (e.g. feature detection using reflection, or strategy/factory pattern boilerplate).

A disadvantage of this system would be that the call-hierarchy at compile time is no longer representative of the call hierarchy at runtime, making it a bit harder to navigate through the code.