I am currently designing a graphics library in Java and now it's come to making the frontend I am curious why I have never seen libraries using global variables for their settings/properties - in-fact some go out of their way to protect them such as JavaScript libraries, and of course choose to use getters and setters such as:Viewport.VSyncEnabled(true)instead of simplyViewport.VSyncEnabled = true;I assume that it is to let the library know what is happening, but there are so many variables that simply don't need monitoring such as output debug data.I would really like to use global variables however if it very against the convention and there are benefits (that I don't know of right now) then I'll be happy to use methods. My reason for wanting to use global variables instead is by my benchmarks it is faster to access directly like that.
Use global variables or methods in an API's frontend
java;design;api