Tutorial :Using classes to hold strings related to software messages


What do you think about the use of public static classes to hold on errorMessages and Ui button names, etc?


   public static class UiMessages      {          public const string ConfirmationDialogTitle = "Atenção";          public const string ConfirmationLandOwnerDelete = "Você tem certeza que deseja deletar os proprietários selecionados?";          public const string ConfirmationProfessionalDelete = "Você tem certeza que deseja deletar os profissionais selecionados?";          public const string ConfirmationGnssDevice = "Você tem certeza que deseja deletar os aparelhos selecionados?";      }  

Is this a bad pratice? Is there a better way to handle this?


This should be of help:


(Whoops, that's for ASP.NET).. try this:


And a good example here:


.NET has localization and globalization support throughout, intended for just this kind of thing.

Hope that helps!


In this case, I would say yes, it is bad practice -- because you likely want internationalization and localization expansion; you may be able to much better utilize properties or resources for such a task.

However, I use similar classes for internal-only (e.g. not displayed to the user) data such as names of data-columns.


In C#, use .resx files and make use of the built-in localization functions.


It's jut another way of defining global variables, and is just as good/bad as any other global variables.

Do these really need to be globally accessible? It would seem that each would only be needed in one class.

The only advance I can see is that you have all the string available in one place if you wanted to translate them into a different language, but that brings us into a whole different area.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »