4 replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/
source | link

Possible Duplicate:
When are Getters and Setters JustifiedWhen are Getters and Setters Justified

Why exactly is having public and private accessors like these:

private string foo;

public string Foo
{
    get
    {
        return foo;
    }
    set
    {
        foo = value;
    }
}

considered better than just having public ones like this:

public string Foo;

The end result seems to be the same.

Possible Duplicate:
When are Getters and Setters Justified

Why exactly is having public and private accessors like these:

private string foo;

public string Foo
{
    get
    {
        return foo;
    }
    set
    {
        foo = value;
    }
}

considered better than just having public ones like this:

public string Foo;

The end result seems to be the same.

Possible Duplicate:
When are Getters and Setters Justified

Why exactly is having public and private accessors like these:

private string foo;

public string Foo
{
    get
    {
        return foo;
    }
    set
    {
        foo = value;
    }
}

considered better than just having public ones like this:

public string Foo;

The end result seems to be the same.

3 insert duplicate link
source | link

Possible Duplicate:
When are Getters and Setters Justified

Why exactly is having public and private accessors like these:

private string foo;

public string Foo
{
    get
    {
        return foo;
    }
    set
    {
        foo = value;
    }
}

considered better than just having public ones like this:

public string Foo;

The end result seems to be the same.

Why exactly is having public and private accessors like these:

private string foo;

public string Foo
{
    get
    {
        return foo;
    }
    set
    {
        foo = value;
    }
}

considered better than just having public ones like this:

public string Foo;

The end result seems to be the same.

Possible Duplicate:
When are Getters and Setters Justified

Why exactly is having public and private accessors like these:

private string foo;

public string Foo
{
    get
    {
        return foo;
    }
    set
    {
        foo = value;
    }
}

considered better than just having public ones like this:

public string Foo;

The end result seems to be the same.

    Post Closed as "exact duplicate" by user8 of
2 Clean up question
source | link

Why is usingare public and private accessors conisderedconsidered good practice?

Why exactly is having public and private accessors (2) considered better than just having public (1) ? The end result seems to be the same.

(1)

public string Foo;

(2)like these:

    private string foo;

    public string Foo
    {
        get
        {
            return foo;
        }
        set
        {
            foo = value;
        }
  }

considered better than just having public ones like this:

public string }Foo;

The end result seems to be the same.

Why is using public and private accessors conisdered good practice?

Why exactly is having public and private accessors (2) considered better than just having public (1) ? The end result seems to be the same.

(1)

public string Foo;

(2)

    private string foo;

    public string Foo
    {
        get
        {
            return foo;
        }
        set
        {
            foo = value;
        }
    }

Why are public and private accessors considered good practice?

Why exactly is having public and private accessors like these:

private string foo;

public string Foo
{
    get
    {
        return foo;
    }
    set
    {
        foo = value;
    }
}

considered better than just having public ones like this:

public string Foo;

The end result seems to be the same.

1
source | link