I have seen in tokens that use the variables decimals and etc as private and create a function to access them, why?
You can find some explanation of visibility in this documentation: https://solidity.readthedocs.io/en/v0.7.4/contracts.html#visibility-and-getters, as for why create a function to access private variables, maybe in order to avoid exposing variables directly, and I think we should ask @abcoathup for a real reason.
(Thanks @Skyge as always for being awesome )
State variables being private is part of the OpenZeppelin Contracts style guidelines:
The explanation for this can be found in the Release notes:
All state variables are now
private, which means that derived contracts cannot access them directly, but have to use getters. This is to increase encapsulation, to be able to reason better about the code.