jQuery in Action, 2nd edition*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes private and public Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "private and public" Watch "private and public" New topic
Author

private and public

friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162
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


swimming certificate (A & B), shoelaces diploma, and some useless java ones.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: private and public
 
Similar Threads
Javadoc of private/protected methods/variables
nx: urlybird 1.3.1 javadoc on private methods & classes
Documentation/JavaDoc Question
Java Reference Material
How to calc bytes written into OutputStream