Hi all,




During work on olingo-832 I realized that the „getEntities“ method in the 
„org.apache.olingo.commons.api.data.EntityCollection“ return the list of 
entities directly (instead of an unmodifiable List).

IMHO the best practice for List handling is to return only unmodifiable Lists 
and offer a method like „addEntity(e:Entity)“ for modification to ensure the 
encapsulation of the data (entities) within the collection object.

As suggested modification the „getEntites“ should return a 
„Collections.unmodifiableList(entities);“ and the EntityCollection gets a new 
method „public void addEntity(Entity e) { entities.add(e);  }“.




I know it is a little bit late to change the API that way, especially because 
we used the „bad practice“ of „getEntities().add(..)“ a lot in the Oligo code 
and tutorial.

Nevertheless I wanted to start a (short) discussion on the dev mailing list 
what do you think about this and if we should change the code or not.




Kind regards,

Michael






Reply via email to