I had this problem many times before, and I never had a solution in which I felt good.
Say I have a Transaction base class and two derived classes AdjustmentTransaction and IssueTransaction.
I have a list of transactions in the user interface, and each transaction is of a specific type of AdjustmentTransaction or IssueTransaction.
When I select a transaction and click on the "Change" button, I need to decide whether to show the AdjustmentTransactionEditorForm or IssueTransactionEditorForm parameter.
The question is, how can I do this in OO without using the switch statement in the type of the selected transaction? The switch statement works, but feels shredded. I feel that I have to somehow use the parallel inheritance hierarchy between transactions and TransactionEditors.
I could have the EditorForm property in my transaction, but this is a terrible mix of my Ai butter UI with my Model chocolate.
Thanks in advance.
source
share