From: Daniel J S. <dan...@ie...> - 2004-08-14 19:46:41
|
Daniel J Sebald wrote: > In having done quite of bit of modular and object oriented code for a > few years, I'd like to discourage the use of global variables across > two conceptually different pieces of code. In particular, in this > instance is the global variable "df_datum". I see now there are several variables made global outside datafile.c: * public variables declared in this file. * int df_no_use_specs - number of columns specified with 'using' * int df_no_tic_specs - count of additional ticlabel columns * int df_line_number - for error reporting * int df_datum - increases with each data point * TBOOLEAN df_binary - it's a binary file * [ might change this to return value from df_open() ] * int df_eof - end of file * int df_timecol[] - client controls which cols read as time Well, then its starting to get to be a lot of work to adhere to a modular strategy. Anyway, things like df_line_number could be done differently. From what I see, that variables is used outside of datafile.c only as an argument to error messages when things fail, e.g., int_error(this_plot->token, "2 columns only possible with explicit pm3d style (line %d)", df_line_number); Another approach might be to create a funciton df_int_error() which acts just like int_error() but in addition tags on information about the file line number it is currently at then calls int_error(). That way, error messages for the line number can be made consistent and easily alter if for some reason more information is to be added. Dan |