l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
January 6: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2002 Sep 20 14:20

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] global variables in C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] global variables in C



On Fri, 2002-09-20 at 11:47, Peter Jay Salzman wrote:
> but i can certainly imagine option 5 (data coupling) being detrimental
> to code maintenance.   when you look at a screen and see a thick dense
> blob of code everywhere.   kind of like how perl can get.  as in, you're
> normally black xterm background looks completely white when you don't
> have your glasses on.

If your functions have too many arguments you can always
start consolidating those arguments into structures to improve
readability.


> to be honest with you, i asked this question because someone challanged
> me to argue the point of "globals are bad".   other than the 2 reasons i
> gave above and the fact that it's conventional wisdom, i really can't
> come up with much.  i was hoping to get some ideas.

I think the argument about coupling is a good one. Functions that
don't change global state are 'isolated' in this sense -- the changes 
the function can make to the program state are restricted by the caller
to the arguments being passed in, whereas in a program with global
variables, the potential changes are much broader in scope, and
therefore harder to think about when you are writing new code.

I agree with you about the wordiness of gtk+. A lot of that is due
to trying to be OO in C. Unless you are writing lots of custom widgets,
you really ought to check out using gtk+ through one of the many 
scripting languages that wrap gtk+ and combining that with the
Glade UI building tool. I have found the combination of Glade/Scheme
to be a breeze. And since scheme has real closures, no need for
funky 'user data' pointers in callbacks!

dave

Attachment: signature.asc
Description: This is a digitally signed message part



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.