Search code examples
javagenericsgeneric-programminggeneric-collections

How to update Non-Generic code to make it Generic?


Currently ,Managing few algorithms which perform set of normal operations on set of Student object.

I wanted to make these algorithm generic , so that we can perform those operations on others Object like Student.

I see in my legacy code base, redundant code can be replaced by Generic-Based Code.

What is best way / good practice for converting Non-Generic code to make it Generic ?


Solution

  • In Java Tutorials there are examples how to convert legacy code to use generics:

    http://docs.oracle.com/javase/tutorial/extra/generics/convert.html

    Java Generics FAQ also has the subsection about dealing with legacy code:

    http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#Coping%20With%20Legacy

    Without examples it's hard to give you something more specific.