I was reading a java book, where it said that when accessing/modifying to variables in different class it should be use the get/set methods to manipulate them.
My question is, overtime and in big projects using gets/sets will not jeopardize the application performance?
Similar question, typically should we preferable use arrays in detriment of more abstract data type (such likened list of instance), since array are normally more cache friendly.
Unless you’re writing some critical section of a high-efficient algorithm that must run in some embedded device, your first goal should be to produce simple, readable, maintainable code. OOP helps us in this regard with some features like encapsulation. Getters and setters allow encapsulating some behavior. They’re also a standard used by several Java technologies (like the JSP EL, various scripting languages, IDEs, etc.). The performance should not be the primary design factor in general.
Java just in time compilers are really smart, and will inline the calls to the getters and setters.
Higher-level abstractions like Java collections also help writing simpler and safer code, and have been tested and optimized. Reimplementing all they provide with arrays would lead to hard-to-maintain, inefficient code. Definitely use the Java collections and prefer them over arrays.
Remember that efficient incorrect code is useless compared to a bit slower correct code.