Why are string identifiers used to access resource data?

I am working on a project to replace the resource management system (QuickTime Resource Manager on Mac and Windows), which is outdated, and I use the current model that Qt uses when data is extracted from the resource file using the key string.

For example, I may have an image in my resource file "HungryBear.png" stored in my resource file. Qt and my proposed system would get this in the manner depicted by psuedocode:

image = GetImageResource("BearPlugin/Images/HungryBear.png"); 

At this point it is clear what kind of image it is and where it can be found.

In our current system, we use numbers. Problems with numbers are what you need to look for a resource file (there can be many) to find out which image (or resource) it is.

An example of this:

 oldActiveResourceFile = GetActiveResourceFile(); // think of a stack of resource files SetActiveResourceFile("BearPlugin"); image = GetImageResource(1); // Perhaps other resources are retrieved and other functions called // Possibly introduce problems by calling functions that change "Active Resource File" SetActiveResourceFile(oldActiveResourceFile); 

The first method is what I saw on current systems that access the data of the resource file. I was told that C # and Java use it, I know what they do for strings with key-key, etc.

However, one of my colleagues expressed concern about changing the current system for using these number identifiers for the line identifiers that I propose. There seem to be many benefits, and they fix many of the problems we had with the current system. I want to have supporting documentation that the proposed system is better and desirable, so my question is this:

Do you know of any studies or discussions that show that using a string identifier (hierarchical) in your code is better than using an arbitrary number?

NOTES

  • I plan to use a zip file (possibly uncompressed) to contain data files.
  • We have a plugin application environment. An application and each plugin can have their own resource files. Plugins can access resource data in the application resource file.
  • Here are some requirements that have been reviewed and, I believe, met:

    • Software developers will be able to uniquely identify resources.
    • Software developers will be able to name resources with meaningful names.
    • Resources must be associated with parts of the application that needs them.
    • Localizers should be able to easily identify resource files that have changed.
    • Localizers should be able to use their own tools to modify resource files.
    • Customers should be warned that the functionality they use depends on outdated calls.
+7
java c # resources
source share
4 answers

The main disadvantages of using identifiers for numeric resources are the ability to detect (find out which resource is 1234) and maintain the uniqueness of identifiers, as you add more time in large applications.

The main disadvantage of using string names for resource identifiers is that strings take up more memory during execution. For example, the .NET template for resources uses line names and tags with line names in the executable file at run time.

String names can easily be kept unique and self-documenting in large applications and years of revisions (using hierarchical paths, as in your example), but the advantage is really only for the convenience of people. It would be nice if these lines could be reduced to integer identifiers for the final executable binary, since the resource pool is unchanged at this point, and the CPU will actually prefer integer identifiers .. NET does not work this way, but other platforms can.

+2
source share
 76 87 123 84 

against

 OpenWithNumericExample OfferStringsInComparison CommentOnGreaterReadabilityOfLatter PointOutGreatDebuggingAdvantageOfLatter 
+1
source share

This type breaks the separation of content from code. The res file is easier to modify than N code files containing hard-coded image links. Perhaps consider the possibility of placing these lines in the Settings object, which gets [de] serialized when loading / unloading.

0
source share

This is much more practical, names can be self-documenting.

Resource resources are often used in internationalization efforts. And there are tools that scan source files, change all lines to function calls to get a resource with the same name, and generate a default mapping.

In code, you can still read what is displayed in langauge by default.

In the translation set, you map the default language to the target language.

This greatly facilitates this process.

0
source share

All Articles