Is it good practice to store sub-collections of item X inside a parent collection of item X for caching 'filter-queries' which are performed on the parent collection? (They won't be used together (as in color AND type).) Or is it also ok to just Loop over the collection and return the correct entities in a temporary collection?
Class ItemCollection : Inherits Collection(Of Item)
Private _types as New List(Of ItemCollection) //Cache
Function FilterByType(type) As ItemCollection
If Not _types.KeyExists(type) Then
_types.Add(type, New ItemCollection())
For Each i in Me
If i.Type = type Then _types(type).Add(i)
Next
End If
Return _types(type)
End Function
//Same for FilterByColor(color)
End Class
Class Item
Public Color = "Blue"
Public [Type] = "One"
End Class