Just wondering, I’m afraid to need to rewrite parts of my code just because I’m decreasing the performance due to my variables. In the end, does it matter? I mean, if I’m able to declare all my variables to private VS. if I declare all my variables to public, it would make a huge difference?
It has no effect on execution speed. The modifiers private
and public
are very high-level, and are only used by the compiler when the code is actually being compiled. In general, it is a good idea to keep as many variables as possible private, not for performance reasons, but to prevent them from being modified accidentally.