Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a difference between storing data in your program or a document file?

I'm developing a text based game and was wondering if there will be any issues if I were to just write all the text in the code instead of making something like a csv file to read the data from. It won't be as organised, but I was wondering if the game would take more memory or have worse performance if I were to put the game in code instead of a text document or csv file.

like image 316
Vulpeeze Avatar asked Sep 10 '18 18:09

Vulpeeze


People also ask

What is the difference between a program file and a data file?

Data, as name suggests, are information processed and stored in files or folders by computer, translated into form that is efficient for movement or processing and can be in form of text documents, images, audio clips, etc. Programs are collection of software instructions understandable by CPU.

Whats the difference between a document and a file?

a file is a named collection of information that is recorded on some kind of storage device, while a document is a type of file that has been created by a particular software application, and can be manipulated by that application (e.g. a word processing document).

Is data and document are same?

The most important difference between My Documents and Application Data is that My Documents is where users store their files, whereas Application Data is where programs store their files.

What is the difference between a document file and a folder?

A file is the common storage unit in a computer, and all programs and data are "written" into a file and "read" from a file. A folder holds one or more files, and a folder can be empty until it is filled.


1 Answers

Some advantages and disadvantages:

In-a-file

  • Easy to modify, easy to localize
  • Not very secure, anyone can look at it and hack it
  • Has to be parsed at runtime, what to do about errors if badly formed?
  • Tiny performance hit on load (probably not worth worrying about)

In an embedded resource

  • No separate file lying on the hard drive for your users to examine and hack (easily)
  • Can localize fairly easily

In-code

  • No need to parse the input file, syntax and structure is checked at compile time
  • Can define your game resources using strongly-typed values, e.g. Room cave = new Room("Cave", "Long description ...").
  • Can define more complex relationships between objects without resorting to string-id references between them. cave.ConnectsTo(passageway), cave.Contains(sword), ...

In terms of memory consumption it's a wash - the strings will be in memory in either case - unless you are writing a huge game in which case a database would be more appropriate with the ability to easily load individual areas of the map and eject ones no longer needed from memory.

like image 190
Ian Mercer Avatar answered Sep 28 '22 10:09

Ian Mercer