1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[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

    11.1%
  2. Default Return Values

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

    88.9%
Thread Status:
Not open for further replies.
  1. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    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. Booch

    Joined:
    Mar 9, 2014
    Messages:
    40
    Likes Received:
    8
    Default Return Values would be good :)
     
  3. dog_

    Joined:
    Nov 3, 2013
    Messages:
    277
    Likes Received:
    95
    Default return values.
     
  4. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,937
    Likes Received:
    1,266
    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. dog_

    Joined:
    Nov 3, 2013
    Messages:
    277
    Likes Received:
    95
    I like.
     
  6. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,937
    Likes Received:
    1,266
    If you want your vote changed, just post here. Changed yours for you dog_.
     
  7. Booch

    Joined:
    Mar 9, 2014
    Messages:
    40
    Likes Received:
    8
    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. House

    Joined:
    Nov 8, 2013
    Messages:
    27
    Likes Received:
    3
    Sounds great.
     
  9. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,937
    Likes Received:
    1,266
    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. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    More than that, but's it's not nearly enough to even make a noticeable difference.
     
  11. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    262
    Likes Received:
    68
    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. Booch

    Joined:
    Mar 9, 2014
    Messages:
    40
    Likes Received:
    8
    How bout the idea of a hybrid script bot that functions for RS3 and OSR?
     
  13. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    262
    Likes Received:
    68
    That was included in my statement.
     
  14. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    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. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,937
    Likes Received:
    1,266
    Thanks for helping shape the API folks. This is what the dev beta release is all about. :D
     
  16. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    262
    Likes Received:
    68
    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. Booch

    Joined:
    Mar 9, 2014
    Messages:
    40
    Likes Received:
    8
    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. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    262
    Likes Received:
    68
    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. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    Decision finalized, hybrid selected.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...