• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using protected access modifier

 
Steve Smith
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

To configure my application, I have decided to implement a GUI. There is one abstract class and then 3 classes which extend it (one for each mode). The abstract class implements most of the functionality but small parts are done in the subclasses using the template method pattern.

The problem I have is that I need access to some of the superclass variables in the subclasses. Would it be best to use getter and setter methods, or is it ok for me to declare my variables as protected in the superclass so that I can access them directly?
 
Muthaiah Ramanathan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do have very similar design like yours. I have used private variables with getters and setters. This getters are setters approach was suggested by checkstyle. However, I am also very keen as what the geeks are to say.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic