Do you use resource file to store all the messages and globlal strings?
Updated by Tiago Araújo [SSW] 3 years ago. See history
123
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.
Catch(SqlNullValueException sqlex){Response.Write("The value cannot be null.");}
❌ Figure: 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"));}
😐 Figure: 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.}
✅ Figure: Good example