Global & Local objects


Hi

I wanna ask a simple question

what is the differences between global and local objects

and whats the usage for it


Thank you
Global objects can be used by anyone. Local objects are limited in scope to their specific function, or control statement.

Generally, avoid global objects for the following reasons:
1. Anyone can modify them at any time. It's hard to be sure that a global object has valid data.
2. Name conflicts get more likely and you might get into problems when using 3rd party libraries, or when combining code from multiple sources.

Namespaces help with the name conflicts, but keeping data limited to the code where it is needed is very important if you want to keep your code from turning into spaghetti.
Topic archived. No new replies allowed.