Lecture overview -- Keyboard shortcut: 'u'  Previous page: The class ObjectSet -- Keyboard shortcut: 'p'  Next page: Generic Types [Section] -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 5 : 21
Object-oriented Programming in C#
Generic Types and Methods
Problems

IntSet, StringSet and ObjectSet suffer from both programming and type problems

  • Problems with IntSet and StringSet

    • Tedious to write both versions: Copy and paste programming.

    • Error prone to maintain both versions

  • Problems with ObjectSet

    • Elements of the set must be downcasted in case we need to use some of their specialized operations

    • We can create an inhomogeneous set

      • A set of "apples" and "bananas"

 

Inhomogeneous sets can also be seen as an advantage