SSW Foursquare

Do you use resource file to store all the messages and globlal strings?

Last updated by Tiago Araújo [SSW] almost 2 years ago.See history

Storing all the messages and global strings in one place will make it easy to manage them and to keep the applications in the same style.

Code StoreMessage
Store messages in the Message.resx

Catch(SqlNullValueException sqlex)
{
Response.Write("The value cannot be null.");
}

Bad example - If you want to change the message, it will cost you lots of time to investigate every try-catch block

Catch(SqlNullValueException sqlex)
{
Response.Write(GetGlobalResourceObject("Messages", "SqlValueNotNull"));
}

OK example - Better than the hard code, but still wordy

Catch(SqlNullValueException sqlex)
{
Response.Write(Resources.Messages.SqlValueNotNull); 'Good Code - storing message in resource file. 
}

Good example

We open source. Powered by GitHub