473,386 Members | 1,790 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,386 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
1 1331
Hello,

"KMZ_state" <KM******@discussions.microsoft.com> wrote in message
news:3F**********************************@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!


What makes sense for your design depends on your requirements. If the CSV
file is small, then loading the entire thing into memory before validating
any of it is just fine. On the other hand, if it can become quite large,
you are better off treating each line as a seperate transaction, just so you
don't have to spend a lot of memory on keeping it all loaded at once.

In general, I'm a fan of Service Oriented Architecture. That means that
when a file is received that contains 1000 records, you would respond with a
file that contains the 5 bad records, and you would accept the rest for
processing. Now, that 'work' can happen at any service interface, and the
'file' that contains the bad records could go to your web site for display,
instead of back to the user... but keep in mind that if you were talking a
SOA system, I'd say that the display mechanism must be completely seperate
from the transaction validation mechanism.

Therefore, if the user uploads data, I'd parse it first. One transaction at
a time: create an object, load the data into the object, validate the
object. If it fails, send it to a service for handling 'bad' messages. If
it passes, send it to the service that persists. Then read the next
transaction.

The service for handing bad messages handles the display/edit/resubmission
process.

I hope this helps,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
Apr 3 '06 #2

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...
6
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.