Definition - What does Collection mean?
In programming, a collection is a class used to represent a set of similar data type items as a single unit. These unit classes are used for grouping and managing related objects.
A collection has an underlying data structure that is used for efficient data manipulation and storage. Code readability and maintenance improves when collections are used in logical constructs.
Techopedia explains Collection
Collections are designed to group certain objects with a logical connection. For example, a StudentCollection object may be used to maintain university student details. Details may include the total number of students or offer a student search facility based on attributes, such as name, class or grade.
Collections are used under the following conditions:
- Each group element represents an object with a similar purpose.
- Group size varies dynamically during runtime.
- There must be access to an individual element through a search function based on a specific key.
- There must be a sort or iteration through the group elements.
The .NET Framework provides a number of collection types, such as an array list, linked list, stack, queue or dictionary. Custom collections may be used when there is an implementation requirement for a special or new data structure. This may be done to host specific types, improve performance or modify by overriding existing collection class functionality. Using custom collections in the application architecture involves additional development resources.
Selecting the right type of collection is based on the usage pattern of a collection. Examples include dictionary collection, queue, stack, sorted dictionary and generics.