Asset Management / GUID

Started by
1 comment, last by ApochPiQ 12 years, 5 months ago
I'm in the planning stages for a small prototype of a much larger project I am considering. The asset handling / management is usually (for me at least) where the failure or success hinges - thus far I have not had a case which resulted in success!

For the prototype I am using a simple language with DX wrapping functionality purely for the prototyping speed it offers. The language itself offers the following which I consider to be useful to the problem in question:

  • Struct-like declarations (Arrays not allowed inside structs)
  • Multi-dimensional arrays
  • Array and function pointers
The metadata for each entity is accessed through a database on the server as this is not time-critical. Rendering-related info (IDs, positions etc.) for each entity must be locally accessible on the client for quick access in calculations.

I don't wish to store everything in a struct array as updating entities would be cumbersome, and it does not allow for much flexibility regarding what data can be stored. Similarly. Really, I would like each entity type to have its own individual struct, but would like a uniform method for accessing data from any entity type.




What I had in mind was a set of functions like:

  • newGroup( groupName )
  • newAssetInGroup( assetName, groupId )
  • getAssetsInGroup( groupId )
  • getAssetByName( assetName )
  • getAssetById( assetId )
  • getAssetAttribute( attributeId )
  • getAssetGroup( assetId )
  • removeAsset( assetId)
The big problem is how to pull this off when I can't use an array inside a struct. So I can do this: group(30).member, but not this: group(30).member(12). The Achilles heel is that you need to be able to refer to and create arrays and members without knowing their absolute name. I am hoping I can do this using pointers. The language doesn't natively support pointers, but fortunately there's a plugin whose commands I have listed below:

Matrix1Util_29

This plug-in provides various useful utilities for manipulating arrays and their contents, plus low-level access to those arrays.

Array Information

ARRAY COUNT
GET ARRAY COUNT
GET ARRAY DIMENSIONS
GET ARRAY INDEX
GET ARRAY ITEM SIZE
GET ARRAY SIZE
GET ARRAYPTR COUNT
GET ARRAYPTR DIMENSIONS
GET ARRAYPTR INDEX
GET ARRAYPTR ITEM SIZE
GET ARRAYPTR SIZE
GET ARRAYPTR TYPE
SET ARRAY INDEX
SET ARRAYPTR INDEX

Array Manipulation

CLEAR ARRAY
CLEAR ARRAY ITEM
CLEAR ARRAYPTR
CLEAR ARRAYPTR ITEM
ROTATE ARRAY
ROTATE ARRAYPTR
SWAP ARRAY ITEMS
SWAP ARRAYPTR ITEMS

Array Sorting

GET ARRAY SORT
GET ARRAYPTR SORT
REVERSE SORT ARRAY
REVERSE SORT ARRAY RANGE
REVERSE SORT ARRAYPTR
REVERSE SORT ARRAYPTR RANGE
SET ARRAY SORT
SET ARRAYPTR SORT
SORT ARRAY
SORT ARRAY RANGE
SORT ARRAYPTR
SORT ARRAYPTR RANGE

Pointers to arrays and array items

GET ARRAY ITEM PTR
GET ARRAYPTR
GET ARRAYPTR ITEM PTR
LINK ARRAY
UNDIM ARRAYPTR
UNLINK ARRAY

UDT Array format

GET ARRAY FIELD COUNT
GET ARRAY FIELD OFFSET
GET ARRAY FIELD TYPE
GET ARRAY FORMAT
GET ARRAYPTR FIELD COUNT
GET ARRAYPTR FIELD OFFSET
GET ARRAYPTR FIELD TYPE
GET ARRAYPTR FORMAT
GET FORMAT SIZE

Loading and Saving arrays

LOAD ARRAY FROM DATAFILE
LOAD ARRAYPTR FROM DATAFILE
SAVE ARRAY TO DATAFILE SAVE ARRAYPTR TO DATAFILE




Using these functions, is it possible to do what I have mentioned? Am I even heading in the right direction, or should I be thinking of some other system?

The problem I see is when you remove an asset. You don't want to just mark it as deleted and leave it there to go stale - especially if you need to do loop through a range of assets. If you delete the array index then you need to make sure you can still access all of the values after the one you just deleted.

I would really appreciate some pointers (no pun intended) on this and thank you all in advance.



Cheers,

Mike
Advertisement
Linked lists could provide the functionality you are looking for.
A few questions:

  • What exactly is your "asset system" meant to do? This is an extremely vague term and means very different things to different people, so it'd help if we could all get on the same page as to what purpose your code serves and what its goals are. One of the biggest pitfalls of software design is not having extremely explicit and concrete goals for individual systems; just from your post alone it seems like you're heading into this trap, although it may just be that you have more detail in mind but haven't typed it up yet - which is fine. We just need to know that detail before we can usefully proceed :-)


  • What's the language you are working with, and why? Prototyping languages can be great when they offer enough functionality to do what you need, but as soon as you encounter a situation where you feel like you're pushing the boundaries of the language to get stuff done, it's time to pick better tools.


  • How will this system be used? Be very wary of the trap of designing general purpose software. It's almost always a mistake. You should, generally speaking, never write code without having a very clear use case in mind. In other words, think from the perspective of someone (possibly yourself) who is tasked with writing code that uses your service. How will they accomplish routine tasks? What will things look like in code? What will the trade-offs be? What will the strengths and weaknesses be, and when will they matter? This ties in a lot with the first question, really, but from the opposite perspective. Instead of planning what features to build, think about what features you will need to use, and what you can live without. Software design is a juggling act and always involves some form of sacrifice; you give up one thing to make it easier to do another. You should be thinking in terms of these balances and focusing your design on what you absolutely need rather than trying to anticipate every possible scenario and struggling to engineer something that can cope with all the options. Minimalism is your best friend ;-)

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement