What layer will I validate a CSV file in?

Discussion in 'ASP .Net' started by =?Utf-8?B?S01aX3N0YXRl?=, Mar 28, 2006.

  1. 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!
    =?Utf-8?B?S01aX3N0YXRl?=, Mar 28, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?S01aX3N0YXRl?=

    sloan Guest

    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" <> wrote in message
    news:...
    > 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!
    >
    sloan, Mar 28, 2006
    #2
    1. Advertising

  3. On Tue, 28 Mar 2006 16:08:01 -0600, KMZ_state
    <> 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
    Craig Deelsnyder, Mar 28, 2006
    #3
  4. 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
    > <> 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
    >
    =?Utf-8?B?S01aX3N0YXRl?=, Mar 29, 2006
    #4
  5. =?Utf-8?B?S01aX3N0YXRl?=

    sloan Guest

    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" <> wrote in message
    news:...
    > 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!
    >
    sloan, Mar 29, 2006
    #5
  6. =?Utf-8?B?S01aX3N0YXRl?=

    sloan Guest

    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" <> wrote in message
    news:...
    > 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!
    >
    sloan, Mar 29, 2006
    #6
  7. 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
    >> <> 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
    Craig Deelsnyder, Mar 29, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?YzY3NjIyOA==?=

    do it in database layer or application layer

    =?Utf-8?B?YzY3NjIyOA==?=, Jan 26, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    418
    Karl Seguin [MVP]
    Jan 27, 2006
  2. et
    Replies:
    2
    Views:
    1,882
  3. =?Utf-8?B?S01aX3N0YXRl?=

    clarification needed: Which layer to validate CSV file?

    =?Utf-8?B?S01aX3N0YXRl?=, Mar 29, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    383
    sloan
    Mar 29, 2006
  4. Federico Bari
    Replies:
    2
    Views:
    1,939
    Federico Bari
    Aug 31, 2003
  5. Dhananjay
    Replies:
    1
    Views:
    1,090
    sloan
    Dec 18, 2006
Loading...

Share This Page