Talk:Collection of Collections Is a Code Smell

From WikiContent

(Difference between revisions)
Jump to: navigation, search

Michael Hunger (Talk | contribs)
(New page: Why not name the CompoundKey by its DomainName i.e. ''Name''. And indexing persons to FirstName, LastName is just one view on a PeopleList. That generic List for people could have differen...)
Next diff →

Revision as of 02:36, 27 January 2009

Why not name the CompoundKey by its DomainName i.e. Name. And indexing persons to FirstName, LastName is just one view on a PeopleList. That generic List for people could have different projections for different views (indices) that use their own indexing. e.g. something like this (just typed in here not thrown at a compiler)

class People {
   private final Collection<Person> people=new ArrayList<Person>();
   public People(Collection<Person> people) {
     this.people.addAll(people);
   }
   public <T extends Projection> SortedMap<T,Person> projectTo(T index) {
      SortedMap<T,Person> projection=new TreeMap<T,Person>();
      for (Person person : people) {
           projection.put(index.from(person), person);
      }
      return projection;
   }

Cascading Collection Poster

--Michael Hunger 18:36, 26 January 2009 (PST)

Personal tools