quote:Original post by davidspornpublic void XXX(){ controler.deleteCurrentFile(); fileList.removeItem(fileList.getSelectedIndex());}
quote:Original post by Advanced Bug
This is what I meant when I said: "depends in an obscure way on the order of operations". It is absolutely not obvious that you must remove the file BEFORE removing the correspoding listbox item.
On the contrary, it IS obvious that you must remove the file before removing the listbox item, because it is the listbox that manages the list of files.
quote:Original post by Advanced Bug
Sure it solves this concrete problem. But there''s no way to predict where similar problem will show up next time. In general, you should be ready to handle an unexpected callback at any point when you call some library function.
Usually when you use a library, callbacks are documented, so a callback is rarely "unexpected". And then, even if it is unexpected, you quickly learn about its existence.
Then, this is one of the purpose of the controler, from the controler developper point of view : to encapsulate each operation to ensure that nothing interfere with the processing in progress.
Beside this, by separating the data from the UI, you will get rid of UI related callback during data processing, i.e. most (if not all) of the callbacks. (this is the famous MVC pattern -Model-View-Controler).
Sure, there''s no way to predict where similar problem will show up next time. But a good design and a relevant and accurate set of requirements will help to avoid a bunch of them, and makes remaining problem less tricky to solve.
----
David Sporn AKA Sporniket