I can't figure out how to avoid parallel hierarchies in practice. e.g. Consider an application which has to create/save/edit notes on different levels, it's a java swing based application.
Domain Hierarchy:
AbstractNote < MonthNote
< DayNote
< ProductNote
read only View Hierarchy(shown on JTabPane each having JTable to show the specific note details)
AbstractNotePanel < MonthNotePanel
< DayNotePanel
< ProductNotePanel
notes editor hierarchy(shown when user clicks on on a particular note in a table row.
AbstractNoteEditorDialog < MonthNoteEditorDialog
< DayNoteEditorDialog
< ProductNoteEditorDialog
I read one way to avoid this is to use Visitor Pattern.here But this doesn't seem to be applicable to my situation.
I'm quite happy with my above design as most of the common code is in abstract class(applying template method pattern there). In case if I have to create a new type of note e.g. YearNote then I have to create YearNotePanel and YearNoteEditorDialog in parallel which is quite acceptable for me cause I don't have to code a lot due to templating. Above all I want to avoid code smell in my design. Please suggest me alternate design in above scenario so that my code would be still modular. Thanks