Hi,

rossberg has left the following comment at Eliminate any library global variable #5 https://www.google-melange.com/gci/task/view/google/gci2014/5028787255246848:


None


First: binu_types isn't a variable but a constant, which normally isn't a problem. We have many constants in BRL-CAD. Often as "define" but "const" should be preferred, people say. Furthermore you moved the constant inside a function which creates an overhead in accessing the values. There should be a good reason for doing this.

This task aims for eliminating global variables. This are changeable values which can be accessed from everywhere in the code. The opposite of them are the local variables in functions and function parameters.

The problem with the global variables is that they can influence the behavior of the program in an unexpected way. Usually a function should use the parameters it was called with only. If there are additional values as global variables which influence the function's result which can be changed anywhere in the program and also from other threads, this can lead to unexpected, hard to explore, effects.

And here it doesn't make a difference if these variables can be accessed directly or via a wrapping function.

To get rid of these global variables one strategy is to change them to local ones and integrate them into function parameters. This could mean to create an additional parameter with this value or to add them to an already existing struct. You may want to aim for global variables which are used in a small set of functions only which are used only a few times. This gives you few places to touch, where you have to change a function parameter list or a struct.


Greetings,
The Google Open Source Programs Team


---
You are receiving this message because you are subscribed to Eliminate any library global variable #5. To stop receiving these messages, go to: https://www.google-melange.com/gci/task/view/google/gci2014/5028787255246848.

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
BRL-CAD Tracker mailing list
brlcad-tracker@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-tracker

Reply via email to