Michael said:
There should *be* no variables that get used everywhere; good OO design
should
(and usually can) ensure that variables and the code that uses them are
encapsulated together in classes so that they don't have to be exposed
widely. At the very least, access should be through getter and setter
methods so that you can at least do some checks.
Getter and setter methods make a lot of sense if you have to control
access to the fields. Java has a few fields that are public and that is
a very convenient way of access them.
Your comment about "passing in" variables that get used everywhere seems
to indicate that you're thinking procedurally, not object oriented.
Us dinosaurs do have a bit of trouble with OO and non-linear programming.
I said that it was bad desing *unless* it's a constant.
I just wrote a program where I needed to set some variables when the
program starts and then use them while the program runs. It made
perfect sense to me to keep those with the rest of the final statics.
This same program had 10 classes each running a thread that needed to be
synchronized during file I/O and data access. The data was in one
class, I/O was in one class, and the Runnable class read the files and
updated the data. Probably one too many classes there but the sync
objects were in a final static array. All class could easily get at
them. Other than combining the data and I/O into one class, how else
could you share an object between the classes?