Do you agree that the logic responsible for asking users for a better
input belongs to the user interface part and it is not a part of the
business logic? I.e. business logic layer have to callback user
interface part when it tries to do the error recovery. So you still have
to pass control to the callee to do the error recovery that business logic part
cannot do on its own as if you were using exception or return codes
style of error handling. To me it looks that the error recovery mechanism is essantially the
same in both cases.
The only difference is added complexity of callback approach. Let's
plot a couple of diagrams. Traditional approach (exceptions or return
codes) for case when the business logic part bails with error:
do some action
handle the error
If at the last point the user interface part can handle the error it
can either ask the business logic part to redo the action or if this error is unrecoverable print
diagnostic error or do something else.
Now callback approach:
UserInterface BusinessLogic UserInte
do some action
This diagram clearly show two problems:
- This design adds additional requirement on reentrability for at
least the user interface and probably for other parts of the system if
the error recovery callback calls them.
- If error recovery callback can handle the error then program flow
is clear. It returns the control to the business logic part which in
its turn returns the control to the callee, i.e. back to the user
interface part. But what about another case when it cannot handle the
error? You still have to return the control back using either
exceptions or return codes! Why then bother with callbacks at all?
Ilya Martynov, email@example.com
CTO IPonWEB (UK) Ltd
Quality Perl Programming and Unix Support
UK managed @ offshore prices - http://www.iponweb.net
Personal website - http://martynov.org
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||