| |||||||
| Programming and Assembly Language Please read this Topic's rules!! |
![]() |
| | LinkBack | Thread Tools | Rate Thread |
| ||||
| Should I use global variables (C# code) gizmo here is the source code and a similar discussion about this issue. You remember we had one here (but in an another thread here). Your ideas?
__________________ Last edited by MrSeanKon; 31st October, 2007 at 06:33 AM. |
| ||||
| Well, in the code you've posted there, I don't see any global variables. While you can change some of the variables to use an array or collection ( message[1].text instead of message1.text ) that's merely a code optimization. In a sense, class variables can be considered globals, but only within the class in which they are defined. Because the scope of access is limited (they can only be accessed within the class, or by using a scope resolution operator such as :: in C++ or . in C#) they aren't the same thing as a true global variable, which has visibility to ALL functions and methods contained in the application (i.e. there is NO way to limit the scope in which the variable may be manipulated). Does that help any?
__________________ Avatar and sig graphic by Pitch. Subscribers! Ask about a custom graphic or avatar today! Gizmo Thermal Diode Mod and Direct-Die Water Block 8-Cheetah 18GiB U-2 SCSI MegaRAID Enterprise 1500/128MiB Samsung SyncMaster 955DF TTGI/Superflower TTS-520 PSU ![]() ![]() ![]() |
| ||||
| gizmo (you know I came from FORTRAN) therefore any external variable in a class I called it global but actually it is not. To summarize you suggest (as the OCUK members) to use external variables cos the Translation routine must store somewhere its values? These values are used by the other functions.
__________________ GRAB overclocking -->OcBible v1.55 Guidemania v1.21 CARDGAMES-->Jack v1.17 Deck v1.13 Preference v1.20 Last edited by MrSeanKon; 31st October, 2007 at 06:33 AM. |
| ||||
| Ah, ok, now I think I see the source of your question. For what you are doing, the way you've written the code is PROBABLY ok. As a matter of style, if it were me, I'd probably alter the code and make the translation function part of its own class, and make those 'global' variables you are using properties of that class with an accessor function for the purpose of reading the variables. Unfortunately, this would entail a significant rewrite of the code.
__________________ Avatar and sig graphic by Pitch. Subscribers! Ask about a custom graphic or avatar today! Gizmo Thermal Diode Mod and Direct-Die Water Block 8-Cheetah 18GiB U-2 SCSI MegaRAID Enterprise 1500/128MiB Samsung SyncMaster 955DF TTGI/Superflower TTS-520 PSU ![]() ![]() ![]() |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Rate This Thread | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Global variables: Do you prefer them? | MrSeanKon | Programming and Assembly Language | 8 | 15th November, 2007 06:33 AM |
| Windows 2000 server login script and how to set variables | Con | Mobile Devices and Networking | 0 | 9th January, 2003 08:19 AM |
| Global Win ????? | SadisticWarrior | Cooling & Temperature Monitoring | 1 | 27th June, 2002 11:49 PM |
| Global Win Tak68 | Southern Man | Cooling & Temperature Monitoring | 5 | 12th May, 2002 08:59 PM |
| SuSE and environmental variables | Kaitain | OS, Software, Firmware, and BIOS | 1 | 25th March, 2002 09:16 AM |