I\'m reading the book \"Clean Code\" and am struggling with a concept. When discussing Objects and Data Structures, it states the following:
Actually by using a Property e.g.
public class Temp
{
public int SomeValue{get;set;}
public void SomeMethod()
{
... some work
}
}
You are hiding its data as there is an implicit variable to store the value set and returned by the SomeValue property.
If you have
public class Temp
{
private int someValue;
public int SomeValue
{
get{ return this.someValue;}
set{ this.someValue = value;}
}
public void SomeMethod()
{
this.someValue++;
}
}
Then you'll see what I mean. You're hiding the object's data someValue and restricting access to it using the SomeValue proiperty.