.net - How should I store const strings such as validation messages? -


like application, use common strings user feedback, validation messages, descriptions, button text , on.

i'd store these strings in logical place. what's ideal method this? don't think matter of opinion; suspect there answer.

i've looked @ other answers such this one, i'm interested in comparison of following 3 methods - i.e. explanation of why 1 technique better other two.

method 1 - resource file

resource files used store strings, best place it? aren't these used localisation? wouldn't resource file big? if use multiple resource files wouldn't hard track down specific strings later?

resource file

method 2 - static class

a sort of global "const" static class store them all?

static class

(a module c# static class)

method 3 - littered throughout relevant classes

with technique have relevant messages @ beginning of class. "useradded" string go in class uses string.

relevant class const

c# or vb.net acceptable in answers.

method 1 - easier localization if ever need later. main benefit of resource files don't need recompile code make text change. change file , upload it. can "too big"? of course, can anything. if so, create multiple resource files.

method 2 - easier make bunch of changes strings, more difficult find each string displayed in app. you'll need logically group strings somehow.

method 3 - easier find string if need change it, if put text relevant classes. downside if need change bunch of strings you'll need go through whole bunch of classes.

if need change strings often, or want write admin tool else can change them, drive them database. that's personal preference.

if hardly ever need change them, put them straight view. (aspx, cshtml or xaml, whatever). after all, that's it's for. how going change "user added successfully"? stick view other programmers first them.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -