A naive implementation of MVC leeds to infinite loops.
Example: Model is a Workbook with Worksheets, View is a Tabbar with Tabs
- User interakts with Tabbar to create new Tab
- Tabbar sends event onTabAdded to Controler
- Controler calls Workbook.addWorksheet()
- Workbook sends event onWorksheetAdded to Tabbar
- Tabbar adds Tab and sends onTabAdded to Controler -> 2) Infinite Loop!
Alternatively, the loop could be initiated by programmatically adding a Worksheet through a macro. Or a tab could be added programmatically by automated UI testing.
It seems that the more components you have and the looser the coupling is (considered good design), the more likely it is to have infinite loops.
Do you know about implementation patterns how to avoid such infinite loops? An evaluation of pros/cons of such patterns?
My special interest is a solution for a rich JavaScript client.
The answers to the following questions are not really on the implementation level: