Almost 60 classes have a function, which sth like this:
List<Group> groups(int p) {
List<Group> groups = new ArrayList<Group>();
groups.add(new GroupA(p));
groups.add(new GroupB(p));
groups.add(new GroupC(p));
return groups;
}
However, it's not readable, and not maintainable (it's more complicated that it is above). What I would like to do is to create generic efficient function something like that:
List<Group> groups(int p) {
return groupFactory(p, GroupA, GroupB, GroupC);
}
I have heard about reflection mechanism, however it is very slow and working dynamically. What I should like to have is something which is generated statically, similarly as template in C++.
Thank You.
Aucun commentaire:
Enregistrer un commentaire