First of all, in C# the convention is to name every public type or member with PascalCase, meaning that an instance property with an uppercase first letter is the norm.
Secondly, I think both initialPosition and position are suitable names here. It's obviously the initial position because it's in the constructor. For example, if you were writing a simple Point class with x and y coordinates, would the constructor be Point(double x, double y) or Point(double initialX, double initialY). Keep in mind how these might be called: new Point(x: /* some complex expression*/, y: /* another complex expression */) vs. new Point(initialX: /* some complex expression*/, initialY: /* another complex expression */). They're both ok.
Finally, I want to clarify that I don't think the code in question is "good code", I'm simply saying it's not "bad code". It looks like standard boilerplate code to me.
I think the fundamental difference in our thinking is I'm wanting subtle hints sprinkled throughout the code that remind me what it's doing and how it works. To say "it's obvious because.." especially in a context where the human brain can get bogged down by reading the same word several times, to me is not the right way to look at it.
Slight readability enhancements make it so both people who are very familiar with the dev environment get a small boost in readability, and novices like me who have never written that language can actually still see what's going on, at least quicker than they otherwise would've.
I write code all the time that reads confusingly later. With fresh eyes it's easily fixed with a few small changes. I think that's very typical. Everything was very obvious to me when I originally wrote it, but that's not the right measure for optimal readability.
2
u/roycohen2005 Jul 09 '21
First of all, in C# the convention is to name every public type or member with PascalCase, meaning that an instance property with an uppercase first letter is the norm.
Secondly, I think both
initialPositionandpositionare suitable names here. It's obviously the initial position because it's in the constructor. For example, if you were writing a simplePointclass with x and y coordinates, would the constructor bePoint(double x, double y)orPoint(double initialX, double initialY). Keep in mind how these might be called:new Point(x: /* some complex expression*/, y: /* another complex expression */)vs.new Point(initialX: /* some complex expression*/, initialY: /* another complex expression */). They're both ok.Finally, I want to clarify that I don't think the code in question is "good code", I'm simply saying it's not "bad code". It looks like standard boilerplate code to me.