This is sparked by this where an OP did not want to add a string he was using for a key lookup because he did not consider it property of the class.
To me the fact you are using it a for a lookup means it is a property. To me anything you search on would be a legitimate property of the class.
Could a lookup key not be considered a property of the class?
Example
class MyClass
{
public string Description
}
Dictionary<string, List<MyClass>> MyClasss
Versus
class MyClassWithName
{
public string Description
public string Name
}
List<MyClassWithName> MyClassesWithName
Yes lookup/search has gone from O(1) to O(n) but has MyClassWithName violated anything?
O(1)
toO(n)
. That's all that really matters, don't you think? – Robert Harvey Apr 28 '17 at 22:04