Michael Hunger wrote: > I'd like to convert the current implementation of factories and > resolvers from having > void addXXX(..., List<XXX> xxx); > to a more query based approach. As by now all of the List<XXX> xxx are > just created just before the method invocation and then filled it is a > much simpler approach and has the additonal beauty of idempotence. > > So having instead a > List<XXX> createXXX(...); > > and use it like List xxx = createXXX(); > or in the case that there is already a partially filled list (which I > didn't encounter by now) > xxx.addAll(createXXX()); > > the XXX are the models created in the factories, the resolutions in the > resolvers etc. > > When refactoring the code this way it became much clearer and easier to > read. The createXXX methods are also more easily testable. > > What do you think?
There are some cases where the list is filled in by two separate methods, but above all some of them are recursive, in which case collections will be unnecessarily created and then combined, instead of simply sending around a "bucket" through the recursive methods. This can of course be solved by doing it in two steps, with one create() method that internally uses the add(...,List) style, which would be fine. /Rickard _______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

