Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 When should I use global, instance, local, and constants in event systems?
#11
Quote:Originally Posted by Trickster at HBGames.Org
Global Variables should generally not be used. Global Variables are not an Object Oriented construct and violates information hiding. You do not want all of the scripts knowing about a variable, you only want your variables shown to methods/classes/scripts that need to view and perform operations on it. The only global variables that should be added are new $data_ and $game_ objects. System global variables created by RMXP (ex. $DEBUG and $scene are allowed). Global variables also consume more memory since they are not removed until the program terminates. The use of bad global variables is frowned upon, because you are cheating yourself, your script, and the users of your script.

Ok for the good OO practice, but the reasoning about the memory does not convince me. Because, the same memory that a global would keep reserved until the program terminates, will be used inside $game_temp, for instance, until the program terminates as well. Only local variables get removed at the end of the method in which they were defined.

Besides, in a way, the use of $game_temp "violates" information hiding as well. :geek:
Reply }


Messages In This Thread
When should I use global, instance, local, and constants in event systems? - by Charlie Fleed - 12-28-2008, 08:03 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Popular Battle Systems kyonides 6 6,377 02-24-2022, 10:40 PM
Last Post: kyonides
Brick Common Event Library (Development + Brainstorm thread) PK8 3 9,023 02-11-2016, 09:25 PM
Last Post: JayRay
   What do you dislike in ATB Systems? DoubleX 18 21,942 06-13-2015, 05:03 AM
Last Post: DoubleX
   What Makes an Event System DerVVulfman 8 12,890 01-19-2010, 09:07 PM
Last Post: Bolt
   What is "event scripting?" PK8 11 16,201 12-19-2008, 11:20 PM
Last Post: PK8



Users browsing this thread: