Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Generics and refactoring...

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anyone seen any articles/catalogs/research on how the presence of generics/templates in a languange influences the choice/availability of refactorings/design patterns?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, Eclipse comes with some automated refactorings for moving pre-5 code to generics, but besides that, no.
 
Eric Nielsen
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was asking because my application seems to be evolving a few parallel components at each level -- two of the fundamental data model items are Lists of X and Lists of Y, which are implemented as rather thin wrapper classes around ArrayList<foo> as appropriate, in the Model Layer. Each has a corresponding ListViewer in the View Layer that's rather isomorphic. Bridging the two is an Editor in the Control Layer that is more unique, but still has some shared functionality.

In some ways it related to the AbstractFactory pattern -- a parameterized family of types that should be used together.

It would be nice to refactor the commonality out of the classes; it looks like the generic that would emerge wuld need to be abstract. While none of the references I've seen on generics talk about what happens when the generic is abstract; the Collection Framework obviously uses it. One difference is that the concrete implementing class would also be binding the type variable at the same time, but I don't see anything that indicates that would be a problem.

However, the complexity of the refactoring and the resulting increasing in complexity of the inheritence/code organization feels a little "unusual". Not a lot of developers (myself included) have a lot of experience with generics (aside friom the Collections) and, thus, the refactoring could make the underlying code harder to work with, not easier....

Does anyone have any experience with using generics to solve issues similar to those solved by abstract factory?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic