11

Not using getters and setters and accesing variables publicly.

Comments
  • 1
    I do that too. Just broke my game this weekend by refactoring to fix this fml
  • 0
    accessing members directly, or use get/set. decide, and then stick to it.
  • 1
    @magicMirror
    In a multi threaded app, how do you control concurrent access to members if you access them directly?
  • 0
    "choose one" means choosing the correct one for your scenario. and the bigger question is why two threads will need write access to the same object fields. refactor your code to eliminate that.
  • 2
    @magicMirror
    Two threads may not need write access to a field. One may write, while another reads. How do you ensure the correct value is read by the second thread? Mutable, non-private members shouldn't be used in a multi threaded app (in my opinion).
  • 1
    Me: using getters and setters, but forgot variables are in public
Add Comment