Is it ok to use a class like this (design / guideline specific)? I’m using MVVM Pattern.
public static class Pages
{
public const string Home = "Home.xaml";
public const string View2 = "View2.xaml";
/* a few more... */
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are significant differences between
constandpublic static readonly, and you should consider which to use with care:(By “client” here, I mean “code in a different assembly referring to the member.)
const. Withpublic static readonly, they will see the updated value. If you recompile all clients anyway, this isn’t a problem.constform is a compile time constant, which means it can be used in:If you’re happy to recompile all your clients if you ever change the value, the benefits of the second bullet point point towards using
const.Of course, I wonder whether
Pagesreally needs to be public anyway… it sounds like something which could beinternal, withinternalmembers – at which point the downsides ofconstgo away entirely.