This is a question that perplexes me about object oriented programming. In some OOP languages (e.g. C++) a member function can access private variables of the class without restriction. That means one can define methods that take no arguments and change the private variables. Isn't this considered bad programming practice? Lots of thought has gone into how function arguments can be passed by value or reference, and what that implies about program complexity.
I would like to make this question less about opinion and more about facts. Let's consider the goto statement. The goto statement has been deprecated as bad programming practice in favor of structured programming. Did any objective data go into that decision? It appears to be intuitive that goto is problematic, but is there a factual basis for the deprecation? Were programs studied, surveys conducted, etc.?
Getting back to my question about member functions, is there an objective basis for answering this question? Should member functions of a class be allowed to manipulate variables not in the argument list? Has there been research to determine this question? Is there a branch of computer science research that attempts to determine best practices in language design based on objective criteria?
Thank you.
this
pointer passed, though only implicitly.