Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4003856
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:12:10+00:00 2026-05-20T08:12:10+00:00

Imagine I have an application that request to the user a name, a category

  • 0

Imagine I have an application that request to the user a name, a category list. When user click on save button, application will save name and category to a database.

I have a layer that get name and category from UI. This layer check if there is a name (a string with length > 0). If this is correct, it will pass name a category to another layer. Note: category is a radiobutton list where one item is always selected.

On this second layer, application will select a suitable class to save name, depending on category.

On last layer, a class will save this name on a database. On this class I will check if name is empty or not.

My question is: where is the right place to check method’s input parameters? on every layer? Maybe, I’m going to use these layers on others developments.

Is my example correct? Maybe, I can left validation on database layer and raise an exception to UI layer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:12:10+00:00Added an answer on May 20, 2026 at 8:12 am

    In general, in terms of the larger question about validating input that is ultimately persisted, it is best to:

    • Convert the input parameters to a
      fully encapsulated business object as
      soon as possible after you receive
      it.

    • Validate early and fail fast then to
      wait until you get to a lower layer
      — waste of resources, waste of time, possibly more complex (more things to
      roll back).

    • Validate the business logic once and make that part of
      your object instantiation process. (but note that validation of view logic and persistence logic may need to be done at the other layers and is separate from business logic)

    • Model how your object is persisted
      using an ORM (e.g., Hibernate) so
      that you could work purely at the
      object level in memory and leave
      persistence as an implementation
      detail. Focus the business logic at
      the object layer.

    And in terms of method validation itself, I agree with Oded — at every layer, and it should be done immediate upon method entry. Again, this is part of the fail fast methodology. But, as I noted above, this doesn’t mean you validate business logic at every method (or every layer). I’m just referring to the basic practice of validating inputs (either by assertions or explicit checks and exceptions thrown).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm designing my database and LINQ To SQL ASP.NET web application. Imagine I have
We have a web-application that lets the users trigger a request to an external
Imagine a web application that allows a logged in user to run a shell
Please imagine you have an live-application with used data in your doctrine-controlled database. Now
I imagine there are many of you out there who have developed an application
Imagine I have these python lists: keys = ['name', 'age'] values = ['Monty', 42,
Imagine I have a process that starts several child processes. The parent needs to
We have an application that is undergoing performance testing. Today, I decided to take
I have an android application that I want to always be running in landscape
We have a console application (currently .NET) that sends out mail in bulk to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.