473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Strings and Resource Files

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?
Bill

Dec 12 '06 #1
4 1731
dw********@gmail.com wrote:
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...

--

(O)enone
Dec 12 '06 #2
While it's hard to imagine this being more performant, it does have the
benefit of taking out hard coded strings out of your application. If you
need to fix or change a message, you need only change the resource file. If
you need to support multiple languages easily then you've got the resource
files for that as well.

<dw********@gmail.comwrote in message
news:11**********************@j72g2000cwa.googlegr oups.com...
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?
Bill

Dec 12 '06 #3
Alright that makes sense. Your reasons for this method are good but
it isn't really applicable for what I am doing. But the rational for
maintaining the messages by a non-developer might give me enough
motivation to do it without grinding my teeth, given that it might be
useful in the future. I just find myself having to "double document"
things. Once in the resource file and then one in the comments.
Before I started doing that I would have to switch to the resource file
a couple times just to find out what was going on in a procedure.

Thanks for the feedback.

Bill

Oenone wrote:
dw********@gmail.com wrote:
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...

--

(O)enone
Dec 13 '06 #4
<dw********@gmail.comwrote:
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'm afraid your boss is a bit confused.

While it's great that he's enforcing this as a coding standard upon you
guys, the only real reason to do it is for either multi-lingual
applications, or applications where you'll need to change messages without
recompiling.

It's actually imposing a performance hit - string access is now being forced
through a resource manager, which is then having to determine your regional
setting, probe for satallite assemblies, and finally return a string from a
resource file.

Compare this to: string s = "test";

Obviously, the 2nd case there is going to far outperform the 1st.

Now, performance aside, you should put your strings in a resource file. It's
a good habit to be in.

--
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins
Dec 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Robert Misiak | last post by:
Hi all- I'm trying to add Windows 98/ME support to an app that previously only supported Windows 2000+. My test box is a running 98 SE. I have a number of localized forms (translated for...
4
by: Phil Da Lick! | last post by:
Hello, Got strings.resx included in my assmebly as the default language neutral collection. ResourceManager res=new ResourceManager("strings", Assembly.GetExecutingAssembly()); string...
1
by: Graham | last post by:
I have to localize a very large web application and therefore have to provide resource strings for all hard-coded strings in the application that will be visible to users Is there a technique for...
1
by: Robin Tucker | last post by:
I notice that although the .NET scheme for creating multi-language applications is generally very good (from the programmers point of view), it seems to be lacking in one important respect: there...
5
by: Sam Carleton | last post by:
I am now many months into a project where the powers that be decided to simply throw static strings in the .Net code. Does anyone know of a tool that will pull out the strings, and put them into...
2
by: Mike P | last post by:
I've always put my connection strings in the web.config, but I've just recently seen an example of a connection string in a resource file. What are the advantages of doing this, and could you do it...
7
by: nws_reader | last post by:
I have a web service that needs to return a particular string for one of its web methods. I would like to manage the strings in a resource file. I went through a lot of the help provided on the...
6
by: Sabiyur | last post by:
Hi All, The application I am doing requires hundreds of strings to be stored & retrieve those randomly. I think I can use microsoft resource ".rc" file to store the strings. I am not sure, how...
1
by: Andrus | last post by:
I have a lot of localizable strings enclosed in double quotes in cs source files. I'm looking for a tool which extracts all those strings for localizaton to a single file. Or even better, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.