PrivateInstanceVariableMandate

While reading through Quality-With-a-Name, which by the way, is a good read, there was point of design interest that James Shore touched upon which i really struggle with sometimes. It’s the PrivateInstanceVariableMandate. How often have we ended up with a class which has the design


class Foo {
private string name;
public string Name {
get { return name; }
set { name = value; }
}

now this kind of class i usually write by rote. Then i’ll pause for a moment to consider the blasphemous

class Foo {
public string name;
}

at which point, i’ll quickly repent and stick with the memorized version but somewhere i know that i’m just not doing a good job of good thinking.

worse yet there are times when i start coding, and in a momentary lapse of reason, the result is the heretical design! then after all is said and done and the check-in is about to be committed, i’ll be reviewing the code with a sense of guilt.
o, the shame! should my college lecturer saw me now…
woe is me! should my peers review my code….

now why does it feel so bad to take the “shortcut” when all my reasoning and powers of logic convince me that there is no real difference between the two designs? except maybe a few lines of code. why is so hard then to break with some hard-lined traditions?