[API-Design] Unsupported Function Exceptions Vs Default Return Values

Discussion in 'Executive Blogs' started by Cloud, Mar 13, 2014.


Unsupported Function Exceptions Vs Default Return Values

  1. Unsupported Function Exceptions

  2. Default Return Values

    0 vote(s)
  3. Hybrid Option (See Arbiter's post below)

Thread Status:
Not open for further replies.
  1. In V1.0.0 Beta 2 The API is designed to throw an exception when a function is used that's not supported in the active game mode. For example, if you try to use Player#getTitle or Player#getAdrenalineGauge in oldschool, an OSRSUnsupportedFunctionException will be thrown. This is a good way to notify a new developer that a function isn't supported in the game mode. The downside is that when creating hybrid scripts bots you either have to have many Environment.isOSRS or Environment.isRS3 calls, or you have to have exception handling code that can make your code more difficult to understand.

    The alternative to this, which could be as implemented as soon as Beta 3 if the community likes it, is to simply return default values and place a RS3Only and OSRSOnly annotation on the method. Examples of default values would be -1 for an int, null for an Object, and an instance of a Collection for any collection (for easier iteration). This would make it so developers would need to be more familiar with the API and javadocs to understand why something is returning a default value, but it would make it easier to create hybrid scripts bots.

    The decision is up to you, vote in the poll and influence the future of the RuneMate API :)
  2. Default Return Values would be good :)
  3. Default return values.
  4. I'd like to add a third option to the table, a hybrid. If the script bot metadata contains the required version (i.e. RS3 only method being called by an RS3 only or hybrid script bot) it returns default return values. If the script bot metadata does not contain the required version (i.e. RS3 only method being called by an OSRS only script bot) it returns an Unsupported Version Exception. That way new developers get the informative exception, and experienced developers don't have to exception handle. Added the hybrid option to the poll. Thoughts?
    Booch and dog_ like this.
  5. I like.
  6. If you want your vote changed, just post here. Changed yours for you dog_.
  7. Actually, change my vote to that. Very nice way of putting it Arbiter, kind of getting best of both worlds. Change my vote please
  8. Sounds great.
  9. Thanks man. Full disclosure, it does add a marginal overhead, equivalent to checking a boolean (which isn't much fyi).
    Assuming you wanted your vote changed, so I did. Let me know if that's not true and I'll change it back.
  10. More than that, but's it's not nearly enough to even make a noticeable difference.
  11. Neither, the developer should figure this out while writing the script bot.

    The script bot should determine which game it's running on and use simple conditions (as simple as a single boolean, even) to determine the method to be used.
  12. How bout the idea of a hybrid script bot that functions for RS3 and OSR?
  13. That was included in my statement.
  14. However if they don't, they can't just have a bizarre error message because the hook isn't available. It needs to fail, but elegantly.

    Edit: The Hybrid solution has been selected, default values if it's a hybrid script bot, with an error message if it's not.
  15. Thanks for helping shape the API folks. This is what the dev beta release is all about. :D
  16. You should just demote the script bot writers who don't know what they're doing or have not properly tested a script bot before releasing it. I'd call that elegant.
  17. I'd agree with the latter. If they're completely clueless about scripting then that too but not everyone is born knowing how to develop software and scripts bots(In this case) so instead of demoralizing them we should encourage, help & teach them.
    Arbiter likes this.
  18. Agreed, they can learn and we can help them. But beginner script bot writers (especially with Botwatch around the corner) should not be releasing public scripts bots. Therefore, elegant error throwing isn't needed, it just needs to be effective.
  19. Decision finalized, hybrid selected.
Thread Status:
Not open for further replies.

Share This Page