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
signature.asc
Description: This is a digitally signed message part
