My boss insists that whenever we use a string we place it in a
resource file every single time. This goes for error string that are
displayed through a message box, constants, ect. He claims that this
adds a huge performance boost in the application but I don't
understand why. Is there something to this?
I don't believe so. My expectation is that you and right and your boss is
wrong (don't you just love bosses?). Using "hard coded" strings, the
compiled code simply refers to the address of the string in the
application's memory space. Using resource files, you would have to use
extra code (= slower) to extract the string from the resource data into a
local variable, and then use that.
If I'm wrong here, I'm sure someone will be along to correct me very
shortly.
There are some good reasons for using resource files for all your strings:
- it makes it vastly easier to localise your application for different
languages. If you want to be able to run it in French, just give the string
resources to a translator and they'll give you back a French translation.
These can then (in theory) be slotted back into a second resource file, and
switching languages is simple.
- it allows non-developers to write and maintain the messages that get
displayed in your application without having to wade though pages of
impenetrable code (which they will most likely introduce syntax error into,
too).
However, if neither of these are relevant and unlikely to become so, IMO
you'd be better off hard coding the strings. Convincing your boss may be
another matter though...