Quote:
Originally Posted by InertiaM
I would agree with JohnH on 2, 1 and 4.
For 3, I prefer to defy convention and use "whatDirection" as I feel "Me.Direction = direction" is messy. Purely my personal preference though.
|
"Me.Direction = direction" may look at bit confusing to a developer, but the key here is what the user sees when using this class. The guideline I had in mind was this from
Constructor Design :
Quote:
|
Do use the same name for constructor parameters and a property, if the constructor parameters are used to simply set the property. The only difference between such parameters and the properties should be casing.
|
So when consumer uses this constructor it should be obvious that the 'direction' parameter is a way to set the 'Direction' property directly when creating the class instance.
Whether is was "Me.Direction = direction" (setting value through property setter) or "Me._direction = direction" (setting value to private field) is just a matter of reuse of existing code if necessary, for example when setter does validation.