00:00
00:00
Newgrounds Background Image Theme

CloudSavage just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Is it a good practice?

381 Views | 4 Replies
New Topic Respond to this Topic

Is it a good practice? 2014-10-06 06:59:56


To use XML as a runtime database?

Response to Is it a good practice? 2014-10-06 08:34:46 (edited 2014-10-06 08:36:52)


Store it however you want, though a lot of people seem to prefer JSON to XML recently.

Whether it's good practice - I'm not sure what you mean. You're just storing volatile data, whether it's in XML or your own format is irrelevant.

Response to Is it a good practice? 2014-10-06 09:04:54


At 10/6/14 08:34 AM, Sam wrote: Store it however you want, though a lot of people seem to prefer JSON to XML recently.

Whether it's good practice - I'm not sure what you mean. You're just storing volatile data, whether it's in XML or your own format is irrelevant.

Should've used differnt wording, I didn't mean database as something outside the program, but a data collection the program uses during runtime, so it uses alot of it, so I guessed it might impact performance.

Response to Is it a good practice? 2014-10-06 09:21:04


At 10/6/14 09:04 AM, NecroBlight wrote: Should've used differnt wording, I didn't mean database as something outside the program, but a data collection the program uses during runtime, so it uses alot of it, so I guessed it might impact performance.

What you're talking about is just some sort of data structure. The benefit of the XML and JSON formats is that they are easily readable by people.

As far as I know, AS3 doesn't have a "type" of JSON, so you'd have to store it as a string and parse it into some data type that's more suitable than a string that AS3 does have before modifying it, and then encode it to a JSON string before writing it back to your variable (essentially writing your own interface between JSON and an AS3 data type, but I'm sure there are third-party classes). I do know AS3 has an XML object but it all depends on what your requirements are.

Considering it's volatile and will be lost once the application is closed, will a human ever read this data? If not, consider the use of an array or something that AS3 already has.

Response to Is it a good practice? 2014-10-06 10:56:27


Not really. XML is designed to be easily readable to humans, so it's likely going to be slower than using other types. If you want something you can assign String keys to then look into Dictionary.

Quick example:

var d:Dictionary = new Dictionary();
d["myName"] = "MintPaw";
d["flashPlayerVersion"] = 15;

If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

BBS Signature