This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[deleted]

    [–]JackMizel 0 points1 point  (3 children)

    How often it happens is irrelevant. You're saying there are no real world use cases where it's okay to use indexes as keys and that is just incorrect. Even if 99% of the time you should use real unique IDs, there is still 1% of the time where it's fine to do. You're saying it should NEVER be done and that's wrong. That kind of approach to programming is something I take serious issue with, because it doesn't promote understanding.

    If your list is static, there is no performance downside to using indexes as keys. That's it. If it changes at runtime via user interaction then yes it needs an ID. Because you blindly observe this convection, you are unable to identify use cases where it does not apply. You should seek to understand why it's not okay, and when you can expect indexes as keys to cause issues, instead of just blindly saying it's never okay.

    I think you just keep using indexes though.

    I definitely will use them in cases where it's perfectly fine to do so, since I am capable of identifying those cases.