How to avoid getters/setters in classes with many instance variables
问题 I'll try to keep it short. I have classes with many instance variables (30+) and hence many getters/setters. The classes by themselves are simple, but because of the getters/setters the LOC just exploded (and there also was way too much code duplicity). So I removed the attributes and stored them in a map, like this public class MyTechnicalToolClassX { //...constructor private Map<String, Object> data; public Object getAttributeByKey(AttributeKey key) { // ...doStuff, check data associated