app.msgBox to automatically abort Transactions

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

app.msgBox to automatically abort Transactions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: app.msgBox to automatically abort Transactions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: app.msgBox to automatically abort Transactions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

by carlranson >> Mon, 18 Aug 2003 20:10:10 GMT

what he said.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: app.msgBox to automatically abort Transactions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

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 ------------------------------------------------------------------


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 12 guests