473,320 Members | 2,000 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,320 software developers and data experts.

What layer will I validate a CSV file in?

We have a debate here. We are receiving a CSV file specified by the user and
need to validate the contents, writing the "good" records to the database and
displaying the "bad" records to the user. One developer wants to loop
through the CSV file right on the web layer (ASPX) and then only pass the
"good" records onto the DAL. The other developer wants to pass the whole
file as an OBJECT to the business logic layer and then loop through there,
passing onto the DAL the "good" records and returning the "bad" records back
to the web layer to be presented to the user.

Is there a "best practice" here? The first developer is looking at the file
as just another user input to be validated, while the other developer is
looking at the file as an object, to be passed through to the BLL. Any
insights or recommendations?? Thanks!

Mar 28 '06 #1
6 1447

The developer who wants to do it on the aspx page is wrong , in my opinion.

The to the bll , and return bad entries approach is acceptable. it depends
if its an "all or nothing" or "most records are ok".

But the code to check the values needs to be in the biz layer.....
You can decide what you want to do if bad records are found.

Process Good Ones, and Return Bad ones.
OR
Pass Back the Bad Ones (as fyi's), and only submit the data once they've
corrected all the data.
The issue of tiered development sometimes equates to "where do I get the
best re-use?"... and putting the code in a aspx code behind is way off on
that mark.

...

Like most things, take my advice with a grain of salt. But I'd argue my
point fervantly, if I was dealing with the scenario.


"KMZ_state" <KM******@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
We have a debate here. We are receiving a CSV file specified by the user and need to validate the contents, writing the "good" records to the database and displaying the "bad" records to the user. One developer wants to loop
through the CSV file right on the web layer (ASPX) and then only pass the
"good" records onto the DAL. The other developer wants to pass the whole
file as an OBJECT to the business logic layer and then loop through there,
passing onto the DAL the "good" records and returning the "bad" records back to the web layer to be presented to the user.

Is there a "best practice" here? The first developer is looking at the file as just another user input to be validated, while the other developer is
looking at the file as an object, to be passed through to the BLL. Any
insights or recommendations?? Thanks!

Mar 28 '06 #2
On Tue, 28 Mar 2006 16:08:01 -0600, KMZ_state
<KM******@discussions.microsoft.com> wrote:
We have a debate here. We are receiving a CSV file specified by the
user and
need to validate the contents, writing the "good" records to the
database and
displaying the "bad" records to the user. One developer wants to loop
through the CSV file right on the web layer (ASPX) and then only pass the
"good" records onto the DAL. The other developer wants to pass the whole
file as an OBJECT to the business logic layer and then loop through
there,
passing onto the DAL the "good" records and returning the "bad" records
back
to the web layer to be presented to the user.


I always put such logic in the business layer; either way you have to
postback and do this work on the server, so bandwidth isn't an issue
(unless your BLL is hosted out-of-process on another server). What
consitutes a 'good record' is a business validation (or perhaps data
layer, if it's truly a passthrough with no corresponding BLL object).
aspx files should only know how to get data it needs from a controller
class and bind/display it to a form, do simple validation, that's it.

My view on it, at least...and some depends on how robust your 3-tier
design is at this point....

--
Craig
Microsoft MVP - ASP/ASP.NET
Mar 28 '06 #3
Clarification: The first developer wants to do the validation in the CODE
BEHIND page, not on the ASPX page per se. Does this change anyone's
responses?

"Craig Deelsnyder" wrote:
On Tue, 28 Mar 2006 16:08:01 -0600, KMZ_state
<KM******@discussions.microsoft.com> wrote:
We have a debate here. We are receiving a CSV file specified by the
user and
need to validate the contents, writing the "good" records to the
database and
displaying the "bad" records to the user. One developer wants to loop
through the CSV file right on the web layer (ASPX) and then only pass the
"good" records onto the DAL. The other developer wants to pass the whole
file as an OBJECT to the business logic layer and then loop through
there,
passing onto the DAL the "good" records and returning the "bad" records
back
to the web layer to be presented to the user.


I always put such logic in the business layer; either way you have to
postback and do this work on the server, so bandwidth isn't an issue
(unless your BLL is hosted out-of-process on another server). What
consitutes a 'good record' is a business validation (or perhaps data
layer, if it's truly a passthrough with no corresponding BLL object).
aspx files should only know how to get data it needs from a controller
class and bind/display it to a form, do simple validation, that's it.

My view on it, at least...and some depends on how robust your 3-tier
design is at this point....

--
Craig
Microsoft MVP - ASP/ASP.NET

Mar 29 '06 #4
No, it doesn't change the response.

I'm sure we all knew that up front, it was the codebehind page, not the
html/aspx page.


"KMZ_state" <KM******@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
We have a debate here. We are receiving a CSV file specified by the user and need to validate the contents, writing the "good" records to the database and displaying the "bad" records to the user. One developer wants to loop
through the CSV file right on the web layer (ASPX) and then only pass the
"good" records onto the DAL. The other developer wants to pass the whole
file as an OBJECT to the business logic layer and then loop through there,
passing onto the DAL the "good" records and returning the "bad" records back to the web layer to be presented to the user.

Is there a "best practice" here? The first developer is looking at the file as just another user input to be validated, while the other developer is
looking at the file as an object, to be passed through to the BLL. Any
insights or recommendations?? Thanks!

Mar 29 '06 #5

Just one more thought.

Data Validation should happen in the biz table, regardless.

Now, with the web, ~sometimes we put validation in the webpage, to save a
server trip.

(Aka, make sure they put in a lastname in the txtLastName input box).

However, this is for saving some roundtrip resources,,, not because its
architecturally correct.

The check for "did the user put in their last name" should ALSO be put in
the biz layer......

That way, if the browser chokes on the javascript ( with asp.net validator
routines), the biz object will still throw the appropriate exception.

Alot of developers forget this.... since they get so used to writing
validation routines in the aspx page .. via the validator controls, or
custom javascript.

The general rule of thumb is this

"What if I need to do this .. in a winforms app?". Now.. you'll see it
makes sense to put the check in the biz object.. to check for a last name.

BECAUSE OF THE NATURE OF THE WEB, you can add the additional javascript
check... to save a trip to the web server, but that's for avoiding a round
trip, not because its correct architectually.

...


"KMZ_state" <KM******@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
We have a debate here. We are receiving a CSV file specified by the user and need to validate the contents, writing the "good" records to the database and displaying the "bad" records to the user. One developer wants to loop
through the CSV file right on the web layer (ASPX) and then only pass the
"good" records onto the DAL. The other developer wants to pass the whole
file as an OBJECT to the business logic layer and then loop through there,
passing onto the DAL the "good" records and returning the "bad" records back to the web layer to be presented to the user.

Is there a "best practice" here? The first developer is looking at the file as just another user input to be validated, while the other developer is
looking at the file as an object, to be passed through to the BLL. Any
insights or recommendations?? Thanks!

Mar 29 '06 #6
KMZ_state wrote:
Clarification: The first developer wants to do the validation in the CODE
BEHIND page, not on the ASPX page per se. Does this change anyone's
responses?

"Craig Deelsnyder" wrote:
On Tue, 28 Mar 2006 16:08:01 -0600, KMZ_state
<KM******@discussions.microsoft.com> wrote:
We have a debate here. We are receiving a CSV file specified by the
user and
need to validate the contents, writing the "good" records to the
database and
displaying the "bad" records to the user. One developer wants to loop
through the CSV file right on the web layer (ASPX) and then only pass the
"good" records onto the DAL. The other developer wants to pass the whole
file as an OBJECT to the business logic layer and then loop through
there,
passing onto the DAL the "good" records and returning the "bad" records
back
to the web layer to be presented to the user.

I always put such logic in the business layer; either way you have to
postback and do this work on the server, so bandwidth isn't an issue
(unless your BLL is hosted out-of-process on another server). What
consitutes a 'good record' is a business validation (or perhaps data
layer, if it's truly a passthrough with no corresponding BLL object).
aspx files should only know how to get data it needs from a controller
class and bind/display it to a form, do simple validation, that's it.

My view on it, at least...and some depends on how robust your 3-tier
design is at this point....

--
Craig
Microsoft MVP - ASP/ASP.NET


no...'same thing' in this discussion. code-behind class is still part
of the UI layer, doesn't change a thing in my comments

--
Craig
Microsoft MVP - ASP/ASP.NET
Mar 29 '06 #7

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

Similar topics

2
by: lawren | last post by:
Students interested may contact directly.
87
by: expertware | last post by:
Dear friends, My name is Pamela, I know little about CSS, but I would like to ask a question I have an image on a web page within a css layer: <DIV ID=MyLayer STYLE = "position:...
7
by: Ali-R | last post by:
Hi all, I am getting a CSV file like this from our client: "C1","2","12344","Mr","John","Chan","05/07/1976"......... I need to validate **each filed value** against a set of rules ,for...
4
by: Big Dave | last post by:
Does anyone have suggestions on how to best handle errors in business objects that are part of a business layer? For example: Public Class Person Private _name as string Public Property Name...
0
by: Steve | last post by:
I have created a tableadaptor in VWD called "MemberUsernameTableAdaptor" with a "GetUsername()" method. The method requires the @username parameter and will then try matching it up in the username...
19
by: Charles Law | last post by:
Take a solution with a project hierarchy along the lines of an n-tier system, so that we have a data layer, business layer and presentation layer. The presentation layer is coupled to the business...
1
by: KMZ_state | last post by:
We have a debate here. We are receiving a CSV file specified by the user and need to validate the contents, writing the "good" records to the database and displaying the "bad" records to the user....
1
by: KMZ_state | last post by:
I posted the following question but wanted to clarify that the developer who wants to validate on the ASPX meant the CODE BEHIND page of the ASPX. Does this make a difference in anyone's...
1
by: Jon | last post by:
Hello all - just a spot of advice required. I'm wanting to write a number of data layers that will be used to carry out the typical CRUD operations against a database - so 1 database will be...
0
by: drawing in aspnet | last post by:
Question about putting the data layer in a separate class library. I keep reading that the data layer should be separated from the presentation layer and put in its own class library. I am...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.