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?
Is it good OO design to have 20-25 instance variables in a JAVA class,
Share
well, if your class represents data holder objects, then it is perfectly Ok to go with that. This design is common in java beans.
for example, If yo you have a class which represents an employee in a company, then it is quite usual, if an employee has 20-25 attributes.
But if you are messing so much instance variables with business methods, then down the line you will face difficulties, as you will not be able to get concentrated and focused business components.
To make it more better architecture-wise, you can consider Inheritance(sub-class) or composition(inner class)