473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Handling Errors wrt ObjectDataSource

One of my chief criticisms of validators in an ASP.NET page is that they can
result in a developer re-implementing much of the "business logic" of a
transaction at the page level.

Assuming we have an object that implements business logic, and that object
is utilised via an ObjectDataSource, I wish to enquire what the correct
method is for handling errors from the business logic object.

For example, there are some circumstances where a transaction cannot be
completed due to a validation error. But for the sake of this discussion,
and to remove any potential for using a "Validator" in a pre-validation
sense, let's assume the "validation error" is due to a
transaction-time-determined consistency-related operation such as an
organisation exceeding their credit limit at the time of placing an order.
Clearly in a multi-user system such a test can only be performed when the
operation is being committed to the database, because otherwise it is
[potentially] subject to violation.

So, with a view to "best practices implementation", how should my business
logic object report such an error? Throw an exception?

And how should my page react to such an exception? Should I be hooking event
handlers onto the Inserted, Deleted (etc) events of ObjectDataSource and
then interrogating the ObjectDataSourceStatusEventArgs object for the
presence of an Exception?

If there is an exception, what would a typical course of action be? Would it
be feasible to somehow inject a message into a ValidationSummary control?

Many thanks

Kevin

Nov 7 '06 #1
2 1744
If I understand your rather wordy hypothesis, it seems you are questioning
whether it is feasible to propagate a business - logic failed transaction
condition up to the UI where page-level validation is being used.

I guess it really boils down to whether or not the page-level field
validators are really concerned with a business - logic condition, and
normally, they are not.

So what I'd be looking at is simply an elegant way to inform the user that
although there was nothing wrong with their inputs, the transaction failed
and show them the reason if appropriate. How you do this is of course
entirely up to you to determine. A simple message on a label should suffice.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Frey" wrote:
One of my chief criticisms of validators in an ASP.NET page is that they can
result in a developer re-implementing much of the "business logic" of a
transaction at the page level.

Assuming we have an object that implements business logic, and that object
is utilised via an ObjectDataSource, I wish to enquire what the correct
method is for handling errors from the business logic object.

For example, there are some circumstances where a transaction cannot be
completed due to a validation error. But for the sake of this discussion,
and to remove any potential for using a "Validator" in a pre-validation
sense, let's assume the "validation error" is due to a
transaction-time-determined consistency-related operation such as an
organisation exceeding their credit limit at the time of placing an order.
Clearly in a multi-user system such a test can only be performed when the
operation is being committed to the database, because otherwise it is
[potentially] subject to violation.

So, with a view to "best practices implementation", how should my business
logic object report such an error? Throw an exception?

And how should my page react to such an exception? Should I be hooking event
handlers onto the Inserted, Deleted (etc) events of ObjectDataSource and
then interrogating the ObjectDataSourceStatusEventArgs object for the
presence of an Exception?

If there is an exception, what would a typical course of action be? Would it
be feasible to somehow inject a message into a ValidationSummary control?

Many thanks

Kevin

Nov 8 '06 #2
Forgive me for my wordiness. I wanted to make sure someone didn't try
subvert the problem by simply "suggesting" I use a validator - when clearly
a validator cannot be used in some circumstances.

As an aside, I don't necessarily agree with your assertion that page-level
field validators are not really concerned with "business logic", except
those validators that are concerned merely with "domain-specific" type
validation (eg. ensuring a date is formatted correctly or something).
Everything else starts to become associated with the "contractual
requirements" of the business logic interface (eg. value X must be between 1
and 10, etc), and viewed in this manner it is entirely possible to implement
a large number of validators under the guise of meeting the contractual
requirements of the interface (ie. to ensure that I give it the right inputs
so it doesn't blow up).
So what I'd be looking at is simply an elegant way to inform the user that
although there was nothing wrong with their inputs, the transaction failed
and show them the reason if appropriate. How you do this is of course
entirely up to you to determine. A simple message on a label should
suffice.
Unfortunately, you've simply reiterated my question and told me to solve it
myself. Hence your answer is really no answer at all (and I say that without
malice, because I appreciate you replying nonetheless). Yes, I understand I
could use a label to issue an error message. I'm looking for "best
practices" methodologies for handling these sorts of problems. Are you
suggesting this is good as it is going to get?

Kevin

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:D8**********************************@microsof t.com...
If I understand your rather wordy hypothesis, it seems you are questioning
whether it is feasible to propagate a business - logic failed transaction
condition up to the UI where page-level validation is being used.

I guess it really boils down to whether or not the page-level field
validators are really concerned with a business - logic condition, and
normally, they are not.

So what I'd be looking at is simply an elegant way to inform the user that
although there was nothing wrong with their inputs, the transaction failed
and show them the reason if appropriate. How you do this is of course
entirely up to you to determine. A simple message on a label should
suffice.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Frey" wrote:
>One of my chief criticisms of validators in an ASP.NET page is that they
can
result in a developer re-implementing much of the "business logic" of a
transaction at the page level.

Assuming we have an object that implements business logic, and that
object
is utilised via an ObjectDataSource, I wish to enquire what the correct
method is for handling errors from the business logic object.

For example, there are some circumstances where a transaction cannot be
completed due to a validation error. But for the sake of this discussion,
and to remove any potential for using a "Validator" in a pre-validation
sense, let's assume the "validation error" is due to a
transaction-time-determined consistency-related operation such as an
organisation exceeding their credit limit at the time of placing an
order.
Clearly in a multi-user system such a test can only be performed when the
operation is being committed to the database, because otherwise it is
[potentially] subject to violation.

So, with a view to "best practices implementation", how should my
business
logic object report such an error? Throw an exception?

And how should my page react to such an exception? Should I be hooking
event
handlers onto the Inserted, Deleted (etc) events of ObjectDataSource and
then interrogating the ObjectDataSourceStatusEventArgs object for the
presence of an Exception?

If there is an exception, what would a typical course of action be? Would
it
be feasible to somehow inject a message into a ValidationSummary control?

Many thanks

Kevin


Nov 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that...
2
by: nunya5200-bidness | last post by:
I hope someone may have some insight to this issue... I would like to know how to properly implement exception handling using the ObjectDataSource control. Specfically, I am doing an insert...
2
by: J055 | last post by:
Hi I've implemented caching for my ObjectDataSource. <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnableCaching="True" CacheDuration="10" CacheExpirationPolicy="Sliding" ...
5
by: Dabbler | last post by:
What is the best way to handle data interpolation between form controls and the actual sql data field. I have radio buttons that need to be interpreted, form values that have to be translated.....
3
by: Howard | last post by:
I use FormView and ObjectDataSource to take user inputs in adduser.aspx page i have <asp:ObjectDataSource ID="ds1" runat="server" TypeName="datapage" InsertMethod="addstudent"> and in my...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
0
by: acnx | last post by:
I have an ntier application. I am trying to determine what is the best practice for handing errors in a datagrid. My datagrids are able to add, update and delete data. I am using a...
1
by: MattC | last post by:
Hi, Given an ObjectDataSource and GridView declared as: <asp:ObjectDataSource runat="server" ID="FullCategoryList" TypeName="AD.App_Code.CategoryDataMapper" SelectMethod="GetCategories"...
2
by: Omar Abid | last post by:
Reason of this project: Error handling is one of the most difficult thing that may afford a programmer. It isn't as easy as you think and handling errors in a program some time can make errors...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.