Why is it a bad programming practice to generally declare symbols as globals?

FAQ #100245

If the symbol editor's option "Add symbols to global table" in PG5 1.3 is checked, a message saying that this is a very bad programming practice will be displayed. Some of the reasons for this statement are listed here:

  • When exporting fupla pages or when adding files (Fupla, IL or Graftec files) of an other CPU the globals contained in these programs won't be imported to the CPU.

  • The programs get less modular

  • The global symbols may be accessed by any module. In some applications this does make sense. On the other hand it may be dangerous (e.g. in context of adding a module that already has existing symbols defined)

  • Drag & Drop in symbol structure doesn't work for global symbols

  • After changing one global symbol, all modules have to be rebuilt (takes more time).

As listed above there is only one case in which it does make sense define a global symbol. This case is if the symbol must be accessible in more than one modules (e.g. Fupla and HMI Editor). If this case isn't given, it is strongly recommended not defining a symbol as global (or public which means the same)!

 

Categories

Local FAQ Deutschland / Fupla

Local FAQ Deutschland / SEdit (IL programming)

Local FAQ Deutschland / Symbol Editor

Last update: 25.05.2015 02:48

First release: 21.10.2004 13:46

Views: 4759

The requested software / document is no longer marketed by Saia-Burgess Controls AG and without technical support. It is an older software version which can be operated only on certain now no longer commercially available products.

Download