|
-
January 24th, 2012, 10:47 PM
#1
Opinions about programming styles
I have written a program as a beginner, which makes extensive use of void functions, and uses a lot of global variables. I'm going to rewrite the program, add a GUI, and try to make the programming style more worthy of showing somebody. I know that most people say global variables should be avoided as much as possible.
The problem with my program is that I use a lot of bool variables which are checked by many functions, so I have a whole bunch of global bools. I also have settings and parameters which need to be know by many functions. Also I have a bunch of gnome clutter variables global so that they can be modified by different functions like motion and click events. And the others are mostly just global out of convenience but could very easily be made local.
What do you think about code like this. Should I go back and try and restructure my code so that I no longer need any global variables? Should I not worry about it too much if some are global when it makes it much more convenient etc.
Also, maybe kind of a nit picky thing, but whats your opinion of this type of format,
Code:
void
clicked_cb (ClutterClickAction *action,
ClutterActor *actor,
gpointer user_data)
vs,
Code:
void clicked_cb (ClutterClickAction* action, ClutterActor* actor, gpointer user_data)
I find the first to be annoying because of how much extra space it takes up, unless the function has a lot of arguments and it gets too long. If you were writing code which will be seen by your teachers etc, would you be concerned about following any of these particular format?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|