I’ve a class in Java which has 25 member variables but only two “useful” methods (excluding setters/getters). I feel as if there are 25 global variables being modified left, right and center, having no idea of what’s going on. Is this normal ? Is there any “good practice” rule which says how many data members and methods can be reasonably encapsulated in a class ?
PS: I searched SO, but apparently this question hasn’t been asked yet.
Thanks for any help !
Adding to the other answers take a look at TooManyFields section of pmd rules.
It is stated there that
The other rules would also come in handy and you could use tools such as pmd and checkstyle to get a better idea about how your code adheres to standards.