There are many reasons why an accessor is preferable to providing
direct access to a data field.
- You can make the data field read-only.
- It provides better documentation that the data field is accessible
- It makes it easier to later change the access behavior (count number
of accesses, whatever).
Some conventions encourage the use of a name that begins with get,
(as in getRank()), but this is not universally followed.