What should be public? What should be private?
As a rule of thumb:
- Classes are public.
- Fields are private.
- Constructors are public.
- Getter and setter methods are public.
- Other methods must be decided on a case-by-case basis.
All of these rules may be freely violated if you have a reason
for doing so. These are simply the defaults that handle 90%
of the cases.
Previous | Next | Top
Last Modified September 25, 1998
Copyright 1997, 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu