RFC - Array vs Dictionary vs Obj Vars vs Global Vars

0 favourites
  • 2 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Apologies if this is in the wrong topic.

    Background: I'm new to Construct, but I have enough programming to cause myself headaches.

    Scenario: Lets say I have five data values I'd like to store and access

    Can anyone give me a informed opinion on why to use an Array vs a Dictionary vs Object with Instance Vars vs Global Vars to store these values?

    Since variables in Construct are all "public" or "globally accessible" (with the except of local variables) it isn't obvious to me why I should or would pick one over another, other than personal preference?

    Global Vars = Seems most programmer friendly and expedient unless I need to iterate over them, but a little voice says "global" that's bad?

    Array = Least programmer friendly but best for iteration?

    Object with Instance Vars = Lets say I create an object with those five instance vars, and then reference "Object.VarName". I could see the advantage if those vars were private and using a public interface, but they are globally accessible, so how is that preferable to Global Vars? Global Vars seem like less overhead.

    Dictionary = A Dictionary is an Object right? How is it different from an Object with Instance Vars? How is a "key" different than an "var name"?

    Does the answer change if I'm dealing with 25 values vs 5 values?

    I hope this makes sense and doesn't come across as negative, I'm very impressed with Construct and I'm just asking for my own improvement.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Or you can just use JSON and Yann 's JSON plugin?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)