Wednesday, June 8, 2016

BENEFITS OF GENERICS


One beneit of using generic classes should now be obvious:
improved correctness. Incorrect types of objects can no longer
be entered into a list. While erroneous attempts to insert
an element could previously be detected only during testing
(and testing can never be complete), they are now detected at
compile time, and type correctness is guaranteed. In addition,
if there is such an error, it will be reported at the point of the
incorrect insertion—not at the
point of retrieving the element,
which is far removed from the
actual error location.
There is, however, a second
beneit: readability. By
explicitly specifying the element
type of collections,
you are providing useful information to human readers of
your program as well. Explicitly saying what type of element
a collection is intended for can make life easier for a
maintenance programmer.

No comments:

Post a Comment

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...