ComputerCraft icon indicating copy to clipboard operation
ComputerCraft copied to clipboard

Use an interface instead of method reflection to call the API

Open SquidDev opened this issue 7 years ago • 2 comments

This makes it easier to verify at compile time that API methods are valid. I also think it makes the API code substantially easier to read, but that may just be me.

SquidDev avatar Feb 24 '18 13:02 SquidDev

I also think it makes the API code substantially easier to read, but that may just be me.

Definitely a much better way to do it! Though if ComputerCraft is using Java 8 then it could be made a little cleaner with Optionals.

theoriginalbit avatar Mar 25 '18 01:03 theoriginalbit

Though if ComputerCraft is using Java 8 then it could be made a little cleaner with Optionals.

It could be made even cleaner on top of that using Guava's Suppliers.memoize (Minecraft/forge already has Guava as a dependency, right?)

e.g. write a supplier to get an optional containing the API impl, memoize it with Guava, and then just use apiSupplier.get().ifPresent(...)

dmarcuse avatar Mar 25 '18 02:03 dmarcuse