# Friday, March 10, 2006

Generics versus Object Arrays

The .Net programmers on my team were debating the concepts of how a generic class is better than an object array. This website seems to explain it well.

Basically, it comes down to this:

  1. If you want to change the item(s) in an array, you have to create a temp storage area, copy them over, make the change to the array, and finally copy the items back. Boo.
  2. You sure could write your own collection class; that would violate the best practice of using the most of the Base Class Library. The less code YOU write, the better. Microsoft has thought about it longer, harder and better than you ever could. Don't re-code the wheel. Geometry and other concepts like pi are easy to flub up.
  3. This site does a handy job of explaining the performance gains seen in generics. The memory footprint stays lower with generics too.
#    Comments [0] |
Comments are closed.