473,698 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1459

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******@discu ssions.microsof t.com> wrote in message
news:6D******** *************** ***********@mic rosoft.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******@discu ssions.microsof t.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******@discu ssions.microsof t.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******@discu ssions.microsof t.com> wrote in message
news:6D******** *************** ***********@mic rosoft.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******@discu ssions.microsof t.com> wrote in message
news:6D******** *************** ***********@mic rosoft.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******@discu ssions.microsof t.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
1326
by: lawren | last post by:
Students interested may contact directly.
87
9585
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: absolute;top:68px; left:563px; width:640px;height:480px;"> <IMG src="ReportImageBox_12.54.52.png" width=640 height=480></IMG>
7
16265
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 instance for "05/07/1976" ,I need to make sure that it's in the right format ,It's not later than today and lots of other rules ,Is there somebody who can help me how to that?Can I map it to some sort of xml schema or something?
4
2061
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 as string Get Return _name End Get Set(Value as string)
0
1163
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 field of a table. As the usernames are all unique, if the username exists a 1 row dataset will be returned, if not the dataset will be empty. Now I want to use the DAL above to validate a username entered by a user to see whether it already...
19
2892
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 layer, and the business layer is coupled to the data layer. So far so good. Suppose the data layer raises an event, and it passes Me (the sender) as an object, and e (MyEventArgs, a descendent of EventArgs) to the layer above (the business...
1
1347
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. 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...
1
1002
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 responses? Thanks. ****** 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...
1
1198
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 linked to 1 data layer. However, I'm aware that typically the connection information, such as the connection string, would be retrived from, in our case, the Web.Config file. This would obviously mean that the user would then have to know this...
0
2403
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 trying to do this but running into a problem. I'm hoping someone can point me in the right direction. I first create a class library (all code in C#) and within this class library create a very simple Sql Server Express database (.mdb) file. It's...
0
8676
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9161
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7732
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6522
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.