Talk:Collection of Collections Is a Code Smell

From WikiContent

(Difference between revisions)
Jump to: navigation, search
Line 20: Line 20:
--[[User:Michael Hunger|Michael Hunger]] 18:36, 26 January 2009 (PST)
--[[User:Michael Hunger|Michael Hunger]] 18:36, 26 January 2009 (PST)
-
Hi Michael, Because it distracts from my main point which still applies with or without the use of generics. Maybe this example is too simple to expose the dangers of only relying on generics for the solution. In this case there is no behavioral loss to using generics. However, that is not always the case.
+
Hi Michael,
 +
 
 +
Nice review. I don't want to use Generics for a number of reasons. The foremost reason is that it distracts from my main point which still applies with or without the use of generics. Also, this code differs in functionality from the code that I'm using in my example. The use of and performance penalty of using an iterator is unnecessary. I can also argue against the use of Generics in this case with the claim that designing with generics robs you of a home for behaviors that are associated with the relationships and other state that would be expressed in the missing design element (the missing class). In other words, this is not an appropriate use of Generics IMHO and I certainly wouldn't condone it by giving it a place in an example.
 +
 
 +
Kirk
Kirk
Kirk

Revision as of 13:41, 4 February 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)

Hi Michael,

Nice review. I don't want to use Generics for a number of reasons. The foremost reason is that it distracts from my main point which still applies with or without the use of generics. Also, this code differs in functionality from the code that I'm using in my example. The use of and performance penalty of using an iterator is unnecessary. I can also argue against the use of Generics in this case with the claim that designing with generics robs you of a home for behaviors that are associated with the relationships and other state that would be expressed in the missing design element (the missing class). In other words, this is not an appropriate use of Generics IMHO and I certainly wouldn't condone it by giving it a place in an example.

Kirk

Kirk

Personal tools