Take for example you have a class A and class B. Class A uses a compositional type relationship that interacts with many of the class B objects. class A stored these class B objects references in an Arralist
Class A
{
ArrayList<B> beeObjects;
}
Is it bad practice to return the Array list data structure if you wanted to implement functionality that interacts with the objects in the arraylist?
Not at all. You can very well return your
ArrayListbeeObjects and use it. In fact, in Object Orient Programming, you would like to do as normal practice provided you have genuine usage scenario.