| ??? 09/09/02 08:57 Read: times |
#28880 - RE: Using/Avoiding Global variables |
"As a rule of thumb, never use global variables in programming."
The reason for this being commonly recommended as Good Practise is for the very reason that all sorts of unforseen (and probably undesirable!) "side-effects" can easily arise if you have all sorts of different parts of your code all fiddling with the same data! Unfortunately, one of the key areas where Global data is particularly valuable is the communication between Interrupt Handlers and the "main" code! It helps to keep your use of "globals" as restricted as possible! There is, of course, also a performance tradeoff in avoiding globals (you trade performance against possible reliability/maintainability issues). For the 8051 in particular, Note also that Global data can't be overlaid - so it can use more RAM! See: http://www.8052.com/forum/rea...&top=28878 In conclusion, I think you should adopt the "never use global variables in programming" as your general rule, and only use Globals where you have specifically determined that they are necessary to your particular application, having carefully considered the pros & cons. |
| Topic | Author | Date |
| Making Global variables interrupt safe? | 01/01/70 00:00 | |
| RE: Making Global variables interrupt safe? | 01/01/70 00:00 | |
| RE: Making Global variables interrupt safe? | 01/01/70 00:00 | |
| RE: Making Global variables interrupt safe? | 01/01/70 00:00 | |
| RE: Making Global variables interrupt sa | 01/01/70 00:00 | |
| RE: Using/Avoiding Global variables | 01/01/70 00:00 | |
| RE: Making Global variables interrupt safe? | 01/01/70 00:00 | |
| RE: Making Global variables interrupt sa | 01/01/70 00:00 | |
| RE: Making Global variables interrupt sa | 01/01/70 00:00 | |
| RE: Making Global variables interrupt sa | 01/01/70 00:00 | |
| RE: Making Global variables interrupt safe? | 01/01/70 00:00 | |
| RE: Making Global variables interrupt safe? | 01/01/70 00:00 | |
| RE: Making Global variables interrupt #2 | 01/01/70 00:00 | |
| RE: Making Global variables interrupt #2 | 01/01/70 00:00 | |
RE: Franc | 01/01/70 00:00 |



