• Post Reply Bookmark Topic Watch Topic
  • New Topic

if a clas has too many private variables, does it violate OO ?  RSS feed

 
mike zhang
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose MyClass.java has 15 private variables and associated setter/getter methods, does this violates a good OO design ? should we limit this number of instance variables to a certain limit to keep a good control on each class ?
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ask yourself, is my class getting beyond a size that would make it hard for someone else to understand, use, fix or extend? Are there common things that could be factored out into a base class?
Remember there are many types of complexities. If your class does too many things, that's one type. If you have too many classes that another type!
Being a skilled software developer means finding a good balance between the two extremes!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!