Re: [gtk-list] Re: Need help in GTK-project



> > you don't have to worry about stomping on
> > other variables, and you can completely change the implementation as
> > long as you leave the interface the same.
> 
> Can't I make the portstatus variabele local in the main() program and
> use some kind of setter functions to set its value, without the use of
> pointers ?

	That's what he was referring to: using "setter functions", as you
call them.

	I admit that I haven't looked at your program, but it's almost
always a bad idea to use global variables.  Instead, you use functions
(that you document!) to set or change the variables.  Those functions are
called an "interface", or API (Application Programming Interface).

	It has some key advantages:

1) You don't need any global variables
2) You can change the type of your variable (i.e., from a gint to a glong,
or even to some abstract struct) and you change the code in your
functions, but the API stays the same.  That is an example of a modular
programming practice

3) You don't need to worry about namespace issues


--Derek



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]