Recently I've been reading some threads about always using properties instead of public fields in C#, but what about private properties? Of course, there are a few threads about it, but they almost always talked about additional logic / lazy-loading etc.
Let's say I have a readonly field that will be accessed all around the Program class, but (at least for now) it's not used anywhere else:
static class Program
{
private static readonly Canvas canvas = new Canvas(100, 30);
// Canvas is like the main class of my game, there can be only one instance of it
static void Main()
{
// ...
canvas.DoSomething();
// ...
}
// ...
// Many other references to "canvas" here
}
or should I do something like this:
private static Canvas Canvas { get; } = new Canvas(100, 30);
The second option means that I can easily make this public, which I might or might not do in the future. And what about other private fields? Are there any rules or guidelines about what should be a private property or not? Or should I declare everything as a field because it's private (although it feels public-ish)?
Just for clarification:
- I'm not making a reusable library, just a console game;
- I'm not going to implement any logic about getting / setting the value;
- I'm writing the Canvas class myself, it's not external.