Psychotechno Posted February 20, 2021 Share Posted February 20, 2021 Noob question incoming When programming my bot to interact with the grand Exchange, I noticed that some snippets use the getGrandExchange() method in the MethodProvider, for example: getGrandExchange().isOpen() And sometimes people don't use the MethodProvider, so they use GrandExchange class directly, like so: if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.PENDING_BUY) { status = "Pending offer"; }else if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.FINISHED_BUY) { status = "Offer completed - Collecting"; } What is the difference between the two? The same applies with Inventory class & getInventory(), Bank class & getBank() etc.... I guess this question could be phrased more generally: What is the difference between using methodProvider get-functions or interacting with the classes directly? Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted February 20, 2021 Share Posted February 20, 2021 (edited) Generally, you should always use getters/setters for variables contained in other classes, if one is provided as they may be doing more than just returning the variable. In example, calling getInventory() instead of just calling the variable could actually be verifying that it is returning the most up-to-date Inventory state, instead of the one that is currently cached. Edited February 20, 2021 by BravoTaco 1 Quote Link to comment Share on other sites More sharing options...