Hello,
It seems to me that using too many variables at class scope in C++ (e.g.
private data members) can be just as bad as having a C program with lots
of global variables. This is especially true for large classes with
lots of methods. The worse part is that even if conventions are used
to assign names to class data members to so as to distinguish them from
other variables, then it still becomes difficult to tell from the
class definition which methods use which variables without looking
at the particular implementation of functions. That is, when we
look at a header file, it is fairly difficult if not impossible
to tell which methods use which data members. This makes it
especially difficult to refactor code. All of this leads me
to wonder whether it is best to pass data members of the
class so as to make it clear which methods use which
variables, and make the methods static. This makes
it really clear to tell which methods use which
private data members: since the methods are
static, they must appear in the parameter
list to the function.
Comments, opinions, and suggestions welcome,
Thanks,
Neil
Comment