Sunday, October 02, 2005

Public property. Keep out!

We've been taught for years to do this:

private string _name;
public string Name
{
get {

return _name;
}
set {

_name = value;
}
}

But now that we know about agile and refactoring doesn't it sound like over-engineering? Shouldn't we simply say?

public string Name;


It's easier to read, uses less screen real estate and we can always change it to the former when we need.

No comments: