473,387 Members | 1,573 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,387 software developers and data experts.

n-tier input and exceptions

I realize that when making a web application, performing input
validation in the browser is good because it prevents postbacks.
However, input checking that goes beyond making sure a value exists or
that it's not alphabetic when it's supposed to be numeric is arguably
best left to the business tier code on the server where there is
access to other data.

My questions, is what's the best way to communicate complicated error
checking failures? I was thinking that it would be to throw exceptions
from the business tier to the GUI tier. However, I'm reading that
maybe that's not the right way to go. Most people feel that exceptions
are slow and should only be used in situations in which the program
could be relatively easily tripped up by forces outside of its control
(like when trying to access a file that the user might have deleted).

So if exceptions are not a good way to go, what's the best way to move
input validation errors between the business and presentation tiers?
How about simply creating and object containing a list of error
messages and have the GUI display them? That's essentially what I was
thinking the exceptions would do.

Dave
Nov 18 '05 #1
2 1234
headware wrote:
I realize that when making a web application, performing input
validation in the browser is good because it prevents postbacks.
However, input checking that goes beyond making sure a value exists or
that it's not alphabetic when it's supposed to be numeric is arguably
best left to the business tier code on the server where there is
access to other data.

My questions, is what's the best way to communicate complicated error
checking failures? I was thinking that it would be to throw exceptions
from the business tier to the GUI tier. However, I'm reading that
maybe that's not the right way to go. Most people feel that exceptions
are slow and should only be used in situations in which the program
could be relatively easily tripped up by forces outside of its control
(like when trying to access a file that the user might have deleted).
A failed precondition for a business component is no less exceptional to me
than some technical issue like a file not found error -- it's not
recoverable and must be reported back to the user.

Using an error object also implies using return values or out/ref parameters
in all business methods. That means explicit checking is required -- which
is the exact reason not to communicate errors in this fashion in the first
place, because it can be ignored (see Win32 ;->).

And as far as performance is concerned... I'd go with a clean design first
before falling for potential myths regarding performance.
So if exceptions are not a good way to go, what's the best way to move
input validation errors between the business and presentation tiers?


I don't see anything wrong with your approach if it's applied to UI layer
(actually, no web framework I'm aware of handles validation errors at UI
level by exceptions). Validation at this level is required anyway, as there
are potentially different validation rules at UI level than at BC level
(data entered on Web forms is text -- data processed by buisness components
should be the "true" data type like dates).

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss.de
Nov 18 '05 #2
Joerg,

I appreciate the reply and you make some good points, especially
regarding the fact that if I don't use exceptions, the only time the
errors will be caught is when people bother to look for them in the
GUI tier. That alone seems to make the use of exceptions the right
option. Which makes me wonder why I don't hear about exceptions being
used in this way more.

Does anyone else have any input on this?

Dave

"Joerg Jooss" <jo*********@gmx.net> wrote in message news:<uS**************@TK2MSFTNGP10.phx.gbl>...
headware wrote:
I realize that when making a web application, performing input
validation in the browser is good because it prevents postbacks.
However, input checking that goes beyond making sure a value exists or
that it's not alphabetic when it's supposed to be numeric is arguably
best left to the business tier code on the server where there is
access to other data.

My questions, is what's the best way to communicate complicated error
checking failures? I was thinking that it would be to throw exceptions
from the business tier to the GUI tier. However, I'm reading that
maybe that's not the right way to go. Most people feel that exceptions
are slow and should only be used in situations in which the program
could be relatively easily tripped up by forces outside of its control
(like when trying to access a file that the user might have deleted).


A failed precondition for a business component is no less exceptional to me
than some technical issue like a file not found error -- it's not
recoverable and must be reported back to the user.

Using an error object also implies using return values or out/ref parameters
in all business methods. That means explicit checking is required -- which
is the exact reason not to communicate errors in this fashion in the first
place, because it can be ignored (see Win32 ;->).

And as far as performance is concerned... I'd go with a clean design first
before falling for potential myths regarding performance.
So if exceptions are not a good way to go, what's the best way to move
input validation errors between the business and presentation tiers?


I don't see anything wrong with your approach if it's applied to UI layer
(actually, no web framework I'm aware of handles validation errors at UI
level by exceptions). Validation at this level is required anyway, as there
are potentially different validation rules at UI level than at BC level
(data entered on Web forms is text -- data processed by buisness components
should be the "true" data type like dates).

Cheers,

Nov 18 '05 #3

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

Similar topics

0
by: tstephan | last post by:
In the past we have used the classic nTier design with COM+, SQL Server and MFC. We are currently working on a new project with an opportunity to use .NET, ADO.NET, etc. One of the areas where I...
25
by: Stuart Hilditch | last post by:
Hi all, I am hoping that someone with some experience developing nTier apps can give me some advice here. I am writing an nTier web app that began with a Data Access Layer (DAL), Business...
5
by: Ryan Ternier | last post by:
I know how this should be done in regards to nTier, but it seems a bit inneficient, and was wondering if there's a solution that I havn't thought of yet. (I'm switching this loop to For Each Row...
1
by: Dnx | last post by:
hi i'm a very beginner of visual studio .net 2003 and aspx/vb.net i have to create a project with an architecture ntier i understand the concept but in practical, i don't know where to begin... ...
14
by: dcassar | last post by:
I have had a lively discussion with some coworkers and decided to get some general feedback on an issue that I could find very little guidance on. Why is it considered bad practice to define a...
0
by: Jon Vaughan | last post by:
Hello, I have an NTIER Model written in VB.NET, at the moment is running as a client / server. Pushing a pulling data from the client to the server is fine and is done via webservice calls. But...
0
by: Jon Vaughan | last post by:
Hello, I have an NTIER Model written in VB.NET, at the moment is running as a client / server. Pushing a pulling data from the client to the server is fine and is done via webservice calls. But...
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...
0
by: fra | last post by:
Ciao a tutti, è disponibile on line un esempio completo di progetto NTier da usare come base per lo sviluppo di una web application strutturata?? Intendo un esempio con gestione corretta dei vari...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.