This is mainly a coding style question. I was wondering if it is a good coding principle to store and get objects from utility classes?
For example, let's say I created a list of integers and I want that list to be used by other classes. However, in order to do this, I have to pass the list inside each class every time I want to use/edit the list. Instead of doing this, is it a good practice to create a utility class that 'gets' this list for me every time I want to use it?
Using a utility class cleans up my code. However, I have heard that it is considered a bad practice to even use a utility class. Thanks!
public class ThisExample {
private static final List<Integer> thisList = new ArrayList<Integer>();
public static List<Integer> getMoveHistory() {
return thisList;
}
}