Answer the question
In order to leave comments, you need to log in
Best way in terms of OOP?
I’ll ask a slightly stupid question, but then I thought, what is the best way to provide an array, say, from a class to a function, from the point of view of OOP?
Publish an existing object and give access to it through a dot (read-only, not for modifications)
Or create a method like public: List get_list() and return this array, reading it through this method, and make the array itself private?
Answer the question
In order to leave comments, you need to log in
in my opinion, from the point of view of OOP (namely, encapsulation), - access to a variable / array is possible only from a class function; And so get() and set() must be implemented for this variable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question