Encapsulate Field

Refactoring

Refactor a private field so that it can only be accessed using getter or setter methods. The advantage is that the accessors can be extended with additional logic without recompiling the client.

In C#, a property is an encapsulated field; in Java we often implement get* and set* methods to access a private field.

Books