Is it good OO design to have 20-25 instance variables in a JAVA class, with their getter/setters?
All variables are totally independent.
As I am using a class in HBase, which represents a column family, so that column family can have different number of columns for each row. So I have to put this much number of variables in that class.
I am very curious to know,
How many instance variables and methods should a JAVA class have ideally?
Trying to have good OO, it is good to look for the class to have a single responsibility. So if you have so many unrelated variables, it sounds like the class is doing too much.
This would be a "code smell" and you should consider re-factoring into multiple classes.
Its great you are interested in good OO. I recommend reading up on Refactoring and Code Smells.
http://c2.com/cgi/wiki?OneResponsibilityRule would be relative here..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With