File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "private and public" Watch "private and public" New topic

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,

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

Joined: Feb 05, 2001
Posts: 17276

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.

Perfect World Programming, LLC - iOS Apps
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:
subject: private and public
It's not a secret anymore!