Using venu#addItem (or any other future approach) should allow specifying
'order' priority:
A higher priority (lower number) for a menu item means that item is displayed before any items with lower priorities (higher number),
'position' priority:
The item can be assigned a prioritized position in the menu (numbers 1-9). If two items have the same prioritized position the item with the higher 'order' priority wins.
Priorities of 0 are ignored and mean that the item has no priority.
Question remains: Where and when should sorting take place?
In venu#register?
Bad in case venu#get would be implemented, as it would be possible to mess with the menu's order
In venu#addItem?
Bad since it would sort for every item added.
The impact might be limited as the number of menu entries should be limited to a reasonable size (navigating through endless menu items is not a good idea...)
Good as it would maintain order at any time.
in venu#print?
Bad since it might impact the time the menu takes to be printed.
Good as it ensures the menu is printed in the right order.
Using
venu#addItem
(or any other future approach) should allow specifyingPriorities of
0
are ignored and mean that the item has no priority.Question remains: Where and when should sorting take place?
venu#register
? Bad in casevenu#get
would be implemented, as it would be possible to mess with the menu's ordervenu#addItem
? Bad since it would sort for every item added. The impact might be limited as the number of menu entries should be limited to a reasonable size (navigating through endless menu items is not a good idea...) Good as it would maintain order at any time.venu#print
? Bad since it might impact the time the menu takes to be printed. Good as it ensures the menu is printed in the right order.