2

By index, I mean, as the user creates the list, each item receives an integer index for its place in that particular list. Since there will be a table of ListItems, I'd prefer to avoid using the name "Index" for the field.

Then I was thinking - should I even include the list index in the database? I figured I would because the list would be created in the same fashion every time, then. Or I could order the list for the user based on its actual primary key, since the list items are created in succession anyway...

What should I do?

3

Presenting the items of a list in the same order is strongly recommended for every GUI. However the ordering logic should be part of the presentation layer. Different users will have different orderings. This should be stored as a user preference.

If you want a simpler solution just use a hardwired ordering, doesn't matter as long as you don't rely on unspecified behavior.

  • Alright, thank you, I was thinking that I should keep it separated. In the end, I believe the GUI will be designed so the user can move items around on the list as they please, so I'll store a numbered ordering for it to be recreated. – Nathan Lutterman Oct 21 '13 at 17:53
  • I disagree with this as an absolute statement. Certainly often the ordering of items is unique to each user, but there are times when the administrator will want to set the order that everyone else sees. – Bobson Oct 21 '13 at 17:59
4

You are correct to avoid using the word index in the column name. I suggest that you avoid names that could be misinterpreted if you have a reasonable substitute.

One option is to call the column "SortOrder" or "DisplayOrder".

Is there a requirement for the list of items to be displayed or sorted in a particular order? If it's not required, you might save time by skipping it. On the other hand, sorting is a feature that many people do not think to ask for until the instant they see something that is not sorted to their liking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.