globals vs parms [was: ... globals.h ...]

David Relson relson at osagesoftware.com
Sat Apr 23 00:50:43 CEST 2005


On Sat, 23 Apr 2005 00:18:16 +0200
Matthias Andree wrote:

> David Relson <relson at osagesoftware.com> writes:
> 
> > On Fri, 22 Apr 2005 00:46:24 +0200
> > Matthias Andree wrote:
> >
> >> David Relson <relson at users.sourceforge.net> writes:
> >> 
> >> > Update of /cvsroot/bogofilter/bogofilter/src
> >> > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22645
> >> >
> >> > Modified Files:
> >> > 	globals.h globals.c 
> >> > Log Message:
> >> > Add bogofilter and bogoutil specific booleans.
> >> 
> >> Uh - is adding complexity really the right thing to do?
> >> I hate those globals, they make the code harder to read.
> >> 
> >> > +bool 	fBogofilter = false;
> >> > +bool 	fBogotune   = false;
> >> > +bool 	fBogoutil   = false;
> >
> > Something like the following could be done:
> >
> > enum e_PROG { P_BOGOFILTE,< P_BOGOTUNE, P_BOGOUTIL }
> 
> Not too useful IMO. If the functions need to know about how they should
> behave, they should be passed an argument, not a global variable.
> 
> The more globals we add, the harder the code gets to understand.

Adding a parameter that must be passed through multiple functions to
get where it's needed is not my idea of the right way to do things.
Straightforward flag variables are easier to deal with.




More information about the bogofilter-dev mailing list