Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

private and public

 
friso dejonge
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
just a couple of questions before uploading.....
did anyone worry about the type of methods they were using and restrict it as much as possible ?
Leaving most of the methods public (out of habit) and only the ones only used inside a class private
Did anyone bother about changing signatures into friendly/protected ?
Did anyone bother to overwrite toString or equals in most of the classes, as suggested by one of the suns design books.
thanks for replies,
friso
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I only had public or private methods, but I did make sure that they were correct. Meaning if the method wasn't designed for any outside classes, I made it private. Same with instance members.
Mark
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Mark on when to use pulic/private. I did have some protected methods/references, because I used a Builder Pattern which uses inheritance to create different types of composites. My feelings, based on an application I wrote (that I still have to maintain) early in my career that had a lot of global identifiers, are that assume private on everything and then gradually ease the restiction until you have the right scope.
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic