Page 1 of 1

app.msgBox to automatically abort Transactions

Posted: Fri Aug 07, 2009 2:44 pm
by ConvertFromOldNGs
by Anonymous >> Mon, 18 Aug 2003 9:05:44 GMT

Looking at implementing this in our top level schema, as such
if process.isInTransactionState then
abortTransaction;
endif;

return inheritMethod(msg, title, flags);

Can anyone see the downside ?

Paul Mathews

Re: app.msgBox to automatically abort Transactions

Posted: Fri Aug 07, 2009 2:44 pm
by ConvertFromOldNGs
by Brendan Doolan >> Mon, 18 Aug 2003 13:39:04 GMT

Paul,
This is not a good idea. Some problems you will hit (I am sure there are many others) are

1. The "view" code is not clearly separated from the "model" or "services" code. In a project of any importance it is a good idea to separate the "view" (forms etc) from the "model" (persistent database structures) since this allows many views of the same model. Mixing them up (as you are doing here) means you will either have to restructure your code or duplicate code to get a different view of your model, for example a Web view.

2. When you code a commitTransaction, it would have to be conditional on not being in transaction state since an app.msgBox may have been done previously. Your transaction boundary is becoming very blurred and the code is becoming messy.

If your application is such that you NEVER want to be in transaction state when doing an app.msgBox (not unreasonable) then a better approach would be to raise an exception or write out some diagnostic information to help you find the bug, since that's what it is in this case. By conditionally committing the transaction you are resolving a side-effect of poor or careless coding and creating others, not fixing the main problem.

Don't do it!

Brendan

Re: app.msgBox to automatically abort Transactions

Posted: Fri Aug 07, 2009 2:44 pm
by ConvertFromOldNGs
by carlranson >> Mon, 18 Aug 2003 20:10:10 GMT

what he said.

Re: app.msgBox to automatically abort Transactions

Posted: Fri Aug 07, 2009 2:44 pm
by ConvertFromOldNGs
by allistar >> Mon, 18 Aug 2003 21:51:43 GMT

As well as what Brendan has already said (all good stuff about keeping the model and view separated) what you want to do should really be handled by an exception handler.

Regards,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------