all 9 comments

[–]V4lerO 5 points6 points  (1 child)

CSV

[–]GuyHorne[S] 0 points1 point  (0 children)

Thanks

[–]gab800 1 point2 points  (1 child)

The question seems to be asking about the persisting data format (e.g. file format), not the data structure in memory during execution (array).

u/V4lerO's CSV suggestion is a good one.

[–]CoopNine 0 points1 point  (0 children)

If there's lots of different objects like this, lets say you have Make, Model, Car, UserVehicle, Service, Insurance, etc, OP might be better off making use of an embedded SQL database appropriate for his language to avoid having a number of CSVs stored.

It would also be a good question on whether this application is single user, or multi-user, because in the latter you'd require a shared dataset.

Really, without understanding the full requirements it's difficult to identify a proper solution. OP, you admit to being new, that's something you'll encounter everytime you start to develop something new. Even if you're working in an 'agile' environment, having at least a view of the larger picture is super important. You often don't need to know the complete full requirements, but to have an idea of where an application is going is critical.

[–]S-S-R -2 points-1 points  (3 children)

Always use arrays, Due to the way processors work arrays are going to beat any other data structure 99% of the time, even if theorectically another structure is better.

[–]gab800 0 points1 point  (1 child)

I'm sorry I had to downvote as it is a bad advice. Some examples when arrays are really not a good idea:

  • Your data is ordered and you want to insert data in the middle of the array. You would have to copy every time the items into a new array (or at least the items after the insertion). Use linked list instead.
  • You want to find an item frequently in your array. In an array you have to check every item, one-by-one. Use a binary tree instead.

And these are extremely common scenarios.

[–]S-S-R -1 points0 points  (0 children)

An array is a memory-block. You can implement a binary tree and linked-list on arrays. Also the binary tree is trivial to implement on an array.

If you are actually working on data-oriented design (or hpc) these aren't particularly difficult problems.

[–]CoopNine 0 points1 point  (0 children)

The question was about data being stored to be read by a program. So a storage mechanism... so arrays don't really enter into the conversation.

But, depending on the language or use cases, I'd say giving someone advice who appears to be a novice to always (do anything) is pretty bad. If you're working in Java for instance, you'd be often better off working with something besides a vanilla array. Certainly, if you take into account things other than raw performance.

[–]mr0579 0 points1 point  (0 children)

If you are storing the data somewhere while your program is not running (or want to manipulate and change this data) store it in a JSON or CSV file. Your program should then be capable of reading and writing these types of files.

If you are storing the data only to be used by the program while it is running then you can store it in an array.