When/why to make function private in class?

You should make a function private when you don’t need other objects or classes to access the function, when you’ll be invoking it from within the class.

Stick to the principle of least privilege, only allow access to variables/functions that are absolutely necessary. Anything that doesn’t fit this criteria should be private.

Leave a Comment