Let's say I have some classes implementing interface Item
and another class MyItemCatalog
that implements interface ItemCatalog
which contains a complex hierarchical database of Item
s that I want to give the user an opportunity to select interactively.
What I would like to do is to have an ItemSelectionDialog
which can be instantiated in one of two ways:
- modal dialog, returns the selected
Item
, or null if none is selected - modeless dialog, allows an application to call a function to retrieve the currently selected
Item
, notifies listeners of changes in the selectedItem
, and provides drag-and-drop capability for a selectedItem
to other applications.
What kinds of things should I keep in mind in architecting this?
Should I try to keep it MVC and decouple the dialog as a view of an underlying model?
Should dialog creation be a static method of a class, or a builder, or what?
Should I create an interface ItemSelectionDialog
and then create a class ItemCatalogSelectionDialog
that implements the interface? (so there could be more than one way to select an item) Except that interfaces can't contain static methods... so should this be a builder class, or created by a method call in MyItemCatalog
?
I'm a bit confused....