methusalah / OpenRTS

Real-Time Strategy game 3D engine coded in pure java
MIT License
1.29k stars 151 forks source link

remove public Fields access #88

Open meltzow opened 9 years ago

meltzow commented 9 years ago

using public fields in classes are bad practice. Is is very hard to use a class if every field and method is public, because everything is changeable and useable. We need a encapsulation of functions. With Eclipse refactoring support, generation of getters and setter are possible. A good workflow is, change the field to private (without refactoing) and use quickfixes to use the getters/setters. While refactoring please take some seconds and think about the fields and his visibility. Private is not the only way. We are implementing a framework which needs to be extends with overriding classes. Somethings there is a need for protected fields.

see more info: https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html