Tweeted twitter.com/StackSoftEng/status/858683827425861633
2 edited body
source | link

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

versusVersus

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?

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?

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?

1
source | link

Is a lookup key a property?

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?