In the Openzeppelin ERC721.sol
contract, there are private variables introduced:
// Token name string private _name; // Token symbol string private _symbol;
These variables are then assigned a public view functions to display their content:
/** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; }
Why are these private instead of public? Nobody can change the values in either of the cases, as mentioned here.