4GL Patterns #1 – Select or Add
A common pattern found in database applications is the “Select or Add” pattern.
The pattern allows a user to either
- select an existing item (usually a foreign key), or
- to add a new item to the foreign key table, then refresh the combo box, and setting the item to the newly added one
The following is a screenshot from Django’s auto-generated administration screens.
The user is presented with a drop-down box, or a plus icon to add new items to the drop-down list.
The following shows an alternate approach, where an “Add” keyword is added to the bottom of a pick list. This approach can be harder to internationalize.
When a new Create Data form is shown to the user, while it may be convenient to make this form modal, so that the parent form can refresh it’s pick list. It may be better to present a non-modal interface so that the user is not blocked from performing other work. This can be done by providing a callback whenever an item is created.
- Stable foreign keys